Skip to content

Instantly share code, notes, and snippets.

@benvium
Created November 28, 2012 11:29
Show Gist options
  • Select an option

  • Save benvium/4160612 to your computer and use it in GitHub Desktop.

Select an option

Save benvium/4160612 to your computer and use it in GitHub Desktop.
Performing a POST in RestKit without all the fiddly object mapping stuff
NSDictionary* dict = @{@"Status": newStatus ? @"On" : @"Off"};
NSString* url = @"/api/status";
[[RKClient sharedClient] post:url usingBlock:^(RKRequest *request) {
[request setBody:dict forMIMEType:RKMIMETypeJSON];
request.onDidLoadResponse = ^(RKResponse* response) {
NSLog(@"status ok %@", response);
if (completion) {
completion(nil);
}
};
request.onDidFailLoadWithError = ^(NSError* error) {
NSLog(@"status error %@", error);
if (completion) {
completion(error);
}
};
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment