Skip to content

Instantly share code, notes, and snippets.

@kitasuke
Created January 17, 2015 08:31
Show Gist options
  • Save kitasuke/38f83e53a4fbb391c2be to your computer and use it in GitHub Desktop.
Save kitasuke/38f83e53a4fbb391c2be to your computer and use it in GitHub Desktop.
Object Mapping with RestKit not using URL connection
NSHTTPURLResponse *httpurlResponse = [[NSHTTPURLResponse alloc] initWithURL:[NSURL URLWithString:@"/hoge/"]
statusCode:200
HTTPVersion:nil
headerFields:@{}];
RKResponseMapperOperation *responseMapperOperation = [[RKResponseMapperOperation alloc] initWithRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"/hoge/"]]
response:httpurlResponse
data:[NSData new]
responseDescriptors:@[
[RKResponseDescriptor responseDescriptorWithMapping:responseMapping
method:RKRequestMethodGET
pathPattern:@"/hoge/"
keyPath:nil
statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)]
]];
RKMapperOperation *mapperOperation = [[RKMapperOperation alloc] initWithRepresentation:@{@"key": @"value"}
mappingsDictionary:responseMapperOperation.responseMappingsDictionary];
[mapperOperation start];
id object = [mapperOperation.mappingResult.array firstObject];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment