Photo *photo = [NSEntityDescription insertNewObjectForEntityForName:@"Photo" inManagedObjectContext:[myFF managedObjectContext]];
photo.name = [key objectForKey:@"name"];
photo.path = [key objectForKey:@"path"];
photo.photoOwner = person;
[[myFF managedObjectContext] save:&error];
[photo release];
The problem lies in the reference counting on the photo object. It turns out that insertNewObjectForEntityForName will return an autoreleased object per the documentation.
Return Value
A new, autoreleased, fully configured instance of the class for the entity named entityName.
Because I am releasing the photo object also it causes the aforementioned error.
Lesson learned: read the documentation!
No comments:
Post a Comment