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
[managedObjectContext performBlock:^{ | |
NSError *error = nil; | |
if (![managedObjectContext save:&error]){ | |
[self handleError:error]; | |
} | |
}]; |
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) allPeopleInManagedObjectContext:(NSManagedObjectContext *)managedObjectContext withCompletion:(void (^)(NSArray*, NSError*))completion { | |
[managedObjectContext performBlock:^{ | |
NSError *error = nil; | |
NSArray *results = nil; | |
NSFetchRequest *fetchRequest = nil; | |
NSPredicate *predicate = nil; | |
NSEntityDescription *entity = nil; | |
fetchRequest = [[NSFetchRequest alloc] init]; | |
entity = [NSEntityDescription entityForName:@"Person" inManagedObjectContext:context]; |
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) saveManagedObjectContext:(NSManagedObjectContext *)managedObjectContext withCompletion::(void (^)(BOOL, NSError *))completio{ | |
managedObjectContext performBlock:^{ | |
NSError *error = nil; | |
if (![managedObjectContext save:&error]){ | |
completion(NO, error); | |
} else { | |
if ([managedObjectContext parentContext] != nil){ | |
[self saveManagedObjectContext:[managedObjectContext parentContext] withCompletion:completion]; | |
} else { |
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) fetchThingsWithCompletion:(void (^)(NSArray *, NSError *))completion{ | |
[context performBlock:^{ | |
result = [context executeFetch:... | |
if (completion != nil){ | |
completion(result, error); | |
} | |
}]; | |
} |
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
NSEntityDescription *entityDescription = nil; | |
NSArray *attributeNames = nil; | |
NSDictionary *mappedValues = nil; | |
entityDescription = [managedObject entity]; | |
attributeNames = [[entity attributesByName] allKeys]; | |
mappedValues = [jsonObject dictionaryWithValuesForKeys:attributeKeys]; | |
[managedObject setValuesForKeysWithDictionary:mappedValues]; |
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
expression = [NSExpression expressionForFunction:@"distanceToLocation:fromLocation:" | |
arguments:@[ | |
[NSExpression expressionForConstantValue:to ], | |
[NSExpression expressionForConstantValue:from ] | |
] | |
]; | |
result = (NSNumber *)[expression expressionValueWithObject:nil context:nil]; |
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
predicate = [NSPredicate predicateWithFormat:@"distanceToLocation:fromLocation:(%@, %@) =< %@", | |
toLocation, | |
fromLocation, | |
expectedDistance | |
]; |
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
entityUserInfo = [entity userInfo]; | |
reKeyedValues = [[NSMutableDictionary alloc] initWithDictionary:jsonObject]; | |
for (NSString *key in keyedValues){ | |
if ([entityUserInfo valueForKey:key] != nil){ | |
[reKeyedValues setValue:[keyedValues valueForKey:key] forKey:[entityUserInfo valueForKey:key]]; | |
// Remove the original key | |
[reKeyedValues setValue:nil forKey:key]; | |
} | |
} |
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
if (__dtrace_isenabled$http_cache$response_from_cache$v1() != 0){ | |
__dtrace_probe$http_cache$response_host_uri_status$v1$63686172202a$63686172202a$696e74(host.UTF8String, path.UTF8String, cached); | |
} |
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 "ProbedURLCache.h" | |
#import "http_cache.h" | |
@implementation ProbedURLCache | |
- (nullable NSCachedURLResponse *)cachedResponseForRequest:(NSURLRequest *)request { | |
NSCachedURLResponse *result = nil; | |
int cached = 0; | |
result = [super cachedResponseForRequest:request]; | |
if (result != nil){ | |
cached = 1; |