Skip to content

Instantly share code, notes, and snippets.

@stevegraham
Created November 7, 2013 21:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevegraham/7362210 to your computer and use it in GitHub Desktop.
Save stevegraham/7362210 to your computer and use it in GitHub Desktop.
// Cannot init an NSManagedObject. Have to insert into an NSManagedObjectContext instance.
NSManagedObjectSubclass * scratchObj = [NSEntityDescription insertNewObjectForEntityForName:@"Foo"
inManagedObjectContext:AppDelegate.managedObjectContext];
// Set the properties on our object, e.g. via UITextField IBOutlets
scratchObj.foo = @"foo";
// Post the object. Assume use of an RKMapping here.
[[RKObjectManager sharedManager] postObject:scratchObj path:nil parameters:nil
success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {
// mappingResult contains the resposne mapped to a new object. So won't there be two
// instances of NSManagedObjectSubclass in my persistent store?
} failure:nil];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment