This file contains hidden or 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
/** | |
Recusivly pre load an array of PFObjects. | |
- parameter items: The items to preload. | |
- parameter completion: Invoked once all loading in the background has been completed. If an error occured it will be passed back otherwise `success` will be `true` with a `nil` error parameter. | |
*/ | |
func preloadItems(items: [PFObject], completion: (success: Bool, error: NSError?) -> ()) { | |
func recursiveLoad(index: Int) { | |
This file contains hidden or 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
#ifndef IS_WIDESCREEN | |
#define IS_WIDESCREEN (fabs((double)[[UIScreen mainScreen] bounds].size.height - (double)568) < DBL_EPSILON) | |
#endif | |
#ifndef IS_IPHONE | |
#define IS_IPHONE ([[[UIDevice currentDevice] model] isEqualToString:@"iPhone"]) | |
#endif | |
#ifndef IS_IPOD | |
#define IS_IPOD ([[[UIDevice currentDevice] model] isEqualToString:@"iPod touch"]) |
This file contains hidden or 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
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ | |
//background processing goes here | |
dispatch_async(dispatch_get_main_queue(), ^{ | |
//update UI here | |
}); | |
}); |
This file contains hidden or 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
NSArray *stores = ...; | |
CLLocation *myLocation = ...; | |
NSMutableArray *nearestStores = [NSMutableArray array]; | |
CLRegion *nearest100kmRegion = [CLRegion initCircularRegionWithCenter:[myLocation coordinate] | |
radius:100000 | |
identifier:@"someIdentifier"]; | |
// We will need to enumerate all stores to ensure that there are no more | |
// than 25 objects within the defined region. |
This file contains hidden or 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
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); | |
dispatch_group_t group = dispatch_group_create(); | |
// Add a task to the group | |
dispatch_group_async(group, queue, ^{ | |
// Some asynchronous work | |
}); | |
// Do some other work while the tasks execute. | |
This file contains hidden or 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
#pragma clang diagnostic push | |
#pragma clang diagnostic ignored "-Wobjc-protocol-method-implementation" | |
// do your override | |
#pragma clang diagnostic pop |
This file contains hidden or 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
UILabel *myLabel.... | |
CABasicAnimation *shake = [CABasicAnimation animationWithKeyPath:@"position"]; | |
[shake setDuration:0.1]; | |
[shake setRepeatCount:2]; | |
[shake setAutoreverses:YES]; | |
[shake setFromValue:[NSValue valueWithCGPoint: | |
CGPointMake(myLabel.center.x - 5,myLabel.center.y)]]; | |
[shake setToValue:[NSValue valueWithCGPoint: | |
CGPointMake(myLabel.center.x + 5, myLabel.center.y)]]; |
This file contains hidden or 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
- (NSInteger)daysBetweenDate:(NSDate*)fromDateTime andDate:(NSDate*)toDateTime | |
{ | |
NSDate *fromDate; | |
NSDate *toDate; | |
NSCalendar *calendar = [NSCalendar currentCalendar]; | |
[calendar rangeOfUnit:NSDayCalendarUnit startDate:&fromDate | |
interval:NULL forDate:fromDateTime]; | |
[calendar rangeOfUnit:NSDayCalendarUnit startDate:&toDate |