Created
December 19, 2011 18:25
-
-
Save cbertoldi/1498279 to your computer and use it in GitHub Desktop.
How to parse a JSON string using RestKit, without loading a remote resource
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 *jsonString = [self readJSON:@"some_file"]; | |
NSDictionary *dictionary = [jsonString objectFromJSONString]; | |
RKObjectMapper *mapper = [RKObjectMapper mapperWithObject:dictionary | |
mappingProvider:[MappingFactory sharedMappingProvider]]; | |
RKObjectMappingResult *result = [mapper performMapping]; | |
// MappingFactory | |
+ (RKObjectMappingProvider *)sharedMappingProvider | |
{ | |
if (! mappingProvider) { | |
mappingProvider = [RKObjectMappingProvider new]; | |
[mappingProvider setMapping:[self createFirstMapping] forKeyPath:@"firstKey"]; | |
[mappingProvider setMapping:[self createSecondMapping] forKeyPath:@"secondKey"]; | |
} | |
return mappingProvider; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment