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
| @import ImageIO; | |
| @import MobileCoreServices; | |
| + (NSArray *) imageMIMETypes { | |
| NSArray *result = nil; | |
| NSMutableArray *mimeTypes = nil; | |
| NSArray *typeIdentifiers = nil; | |
| typeIdentifiers = (__bridge_transfer NSArray*)CGImageSourceCopyTypeIdentifiers(); | |
| mimeTypes = [[NSMutableArray alloc] init]; |
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
| - (void) setDateString:(NSString *)string { | |
| NSDate *date = [someDateThing dateFromISO8601String:string]; | |
| return [self setDate:date]; | |
| } |
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
| 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 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
| - (void) setFirst_name:(NSString *)name { | |
| return [self setFirstName:name]; | |
| } |
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
| 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 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
| NSString * const JSONPersonFirstNameKeyPath = @"firstName"; | |
| NSString * const JSONPersonLastNameKeyPath = @"lastName"; | |
| @implementation JSONPersonDataSource | |
| - (instancetype) initWithJSON:(id)json { | |
| if ((self = [super init])){ | |
| jsonObject = json; | |
| } | |
| return self; |
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
| @protocol PersonDataSource | |
| - (NSString *)firstName; | |
| - (NSString *)lastName; | |
| @end |
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
| NSError *error = nil; | |
| id jsonObject = nil; | |
| jsonObject = [NSJSONSerialization JSONObjectWithData:data options:options:NSJSONReadingAllowFragments error:&error]; | |
| if (jsonObject != nil){ | |
| [self dostuffWith:jsonObject]; | |
| } else { | |
| [self presentError:error]; | |
| } |
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
| - (void)setValue:(id)value forUndefinedKey:(NSString *)key { | |
| return; | |
| } |
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
| [NSURLConnection sendAsynchronousRequest:request queue:[self connectionQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) { | |
| if (response != nil){ | |
| /// Yay, we were able to connect! | |
| } else { | |
| [self presentError:connectionError]; | |
| } | |
| }]; |