This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Problem: Collection View data does not appear after calling [UICollectionView reloadData] in [PFQuery findObjectsInBackgroundBlock:] | |
// Symptoms: The correct number returns in numberOfItems: but cellForItem: is never called | |
// Solution: Try performing collection view updates manually via performBatchUpdates: or reloadItemsAtIndexPaths: or reloadSectionsAtIndexSet: | |
- (void)queryForPhoto { | |
NSLog(@"%s", __PRETTY_FUNCTION__); | |
PFQuery *query = [PFQuery queryWithClassName:@"Image"]; | |
PFUser *user = [PFUser currentUser]; | |
[query whereKey:@"user" equalTo:user]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Intent: Create a 7-Column collection view where the first and last column are wider than the middle columns | |
// Solution: Via the UICollectionViewDeleateFlowLayout calculate the correct size of the cells | |
const NSUInteger daysInWeek = 7; | |
const CGFloat cellHeight = 54.f; | |
const CGFloat sizeRatioForWeekStartEnd = 0.20; | |
const CGFloat sizeRatioForMiddleDays = (1 - (2 * sizeRatioForWeekStartEnd)) / (daysInWeek - 2); | |
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath { | |
CGSize cellSize = CGSizeZero; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Problem: AVAudioRecorder failed to initialize by crashing on initialization method | |
// Diagnosis: NSURL *audioURL was nil at audioRecorder initiliazation point because audioURL's weak declaration | |
// Solution: Declare NSURL *audioURL as strong to ensure it does not get deallocated prematurelys. | |
// *Side note suggestion: Be sure to use [AVAudioRecorder record] instead of prepareToRecord since record will call it implicitly | |
// and handle errors appropriately! | |
// properties | |
// @property (weak, nonatomic) NSURL *audioURL; /* User's original declaration */ | |
@property (strong, nonatomic) NSURL *audioURL; | |
@property (strong, nonatomic) AVAudioRecorder *audioRecorder; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)willTransitionToTraitCollection:(UITraitCollection *)newCollection withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator { | |
[super willTransitionToTraitCollection:newCollection withTransitionCoordinator:coordinator]; | |
NSLog(@"nav size %@", NSStringFromCGRect(self.navigationController.navigationBar.bounds)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum PersonDescription { | |
case Singular, Dual, Plural | |
struct Portrayal { | |
var literal: String, numeral: Int | |
} | |
var portrayal: Portrayal { | |
switch self { | |
case .Singular: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "DynamicScrollviewResizingViewController.h" | |
@interface DynamicScrollviewResizingViewController () | |
@property (weak, nonatomic) IBOutlet UILabel *dynamicLabel; | |
@end | |
@implementation DynamicScrollviewResizingViewController | |
- (void)viewDidLoad { | |
[super viewDidLoad]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// In both versions, we're feeding a string to the NSFileManager method, but only the second one succeeds. In the debugger console, they both appeared with the file:// so it was a bit difficult to debug. Of course, I'd momentarily forgot about every. other. time. it has happened. | |
// Version 1 | |
- (BOOL)fileExistsInCaches:(NSString *)filename | |
{ | |
NSString *path = [NSString stringWithFormat:@"%@%@",[self cacheDirectory],filename]; | |
// path = file://Users/mthongvanh/etc/etc/etc | |
return [[NSFileManager defaultManager] fileExistsAtPath:path]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Debug Log Statement | |
---------------------- | |
DLog(@"\n<#debugging message#> <#%@#>",<#args#>); | |
NSString Convenience Method | |
---------------------------- | |
[NSString stringWithFormat:@"<#%@#>",<#args#>] | |
Dispatch Asynchronously on Main Queue | |
------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"agendaFilters": [{ | |
"id": 1, | |
"display": "Conferences", | |
"value": "conferences", | |
"valueType": "decisionTree", | |
"filterType": "", | |
"options": [{ | |
"id": 1, | |
"display": "Ellucian Live", |