Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>To post an object what I do is associate a <em>path</em> to an <em>object</em>. Then use the method <strong>postObject</strong> from <strong>RKObjectManager</strong>. </p> <p>I asume that you have already configured RestKit so you have the base path set and defined the object mapping for your CDIssue as you have in the code that you already have. With that in mind try this code:</p> <pre><code>//We tell RestKit to asociate a path with our CDIssue class RKObjectRouter *router = [[RKObjectRouter alloc] init]; [router routeClass:[CDIssue class] toResourcePath:@"/path/to/my/cdissue/" forMethod:RKRequestMethodPOST]; [RKObjectManager sharedManager].router = router; //We get the mapping for the object that you want, in this case CDIssue assuming you already set that in another place RKObjectMapping *mapping = [[RKObjectManager sharedManager].mappingProvider objectMappingForClass:[CDIssue class]]; //Post the object using the ObjectMapping with blocks [[RKObjectManager sharedManager] postObject:myEntity usingBlock:^(RKObjectLoader *loader) { loader.objectMapping = mapping; loader.delegate = self; loader.onDidLoadObject = ^(id object) { NSLog(@"Got the object mapped"); //Be Happy and do some stuff here }; loader.onDidFailWithError = ^(NSError * error){ NSLog(@"Error on request"); }; loader.onDidFailLoadWithError = ^(NSError * error){ NSLog(@"Error on load"); }; loader.onDidLoadResponse = ^(RKResponse *response) { NSLog(@"Response did arrive"); if([response statusCode]&gt;299){ //This is useful when you get an error. You can check what did the server returned id parsedResponse = [KFHelper JSONObjectWithData:[response body]]; NSLog(@"%@",parsedResponse); } }; }]; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload