Created
January 30, 2012 21:00
-
-
Save atomicbird/1706663 to your computer and use it in GitHub Desktop.
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
[theCreatingMOC performBlockAndWait:^{ | |
// Insert some test data... | |
NSManagedObject *thePerson = [NSEntityDescription insertNewObjectForEntityForName:@"Person" inManagedObjectContext:theCreatingMOC]; | |
[thePerson setValue:@"Steve Jobs" forKey:@"name"]; | |
NSManagedObject *theCompany = [NSEntityDescription insertNewObjectForEntityForName:@"Company" inManagedObjectContext:theCreatingMOC]; | |
[theCompany setValue:@"Apple" forKey:@"name"]; | |
[theCompany setValue:[NSSet setWithObject:thePerson] forKey:@"employees"]; | |
NSError *thePermanentIDError = nil; | |
[theCreatingMOC obtainPermanentIDsForObjects:[NSArray arrayWithObject:theCompany] error:&thePermanentIDError]; | |
NSLog(@"Permanent ID error: %@", thePermanentIDError); | |
// And save it... | |
NSError *theError = NULL; | |
[theChildMOC save:&theError]; | |
NSLog(@"MOC Saved (%@)", theError); | |
// Store a object URL so we can do our magic in whatever MOC we want... | |
theCompanyURL = theCompany.objectID.URIRepresentation; | |
NSLog(@"%@", theCompanyURL); | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment