Hi
I parse an xml file containing books, for each new node I go:
Book *book = (Book*)[NSEntityDescription insertNewObjectForEntityForName:@"Book" inManagedObjectContext:managedObjectContext];
To obtain an NSManagedObject of my Core Data Book Entity, I then proceed to populate the managed Book object with data, add it to an array, rinse, repeat.
When I am done, I present the list of books to the user. I have not yet executed the save:
NSError *error;
if (![managedObjectContext save:&error]) {
NSLog(@"%@", [error domain]);
}
The user now selects one of the books, this one I would like to persist, but only this one, all the other books are of no interest to me any more. The Book Entity does not have/or is part of any relationships. It is just a "single" Entity.
If I pull the "save lever" every Book object will be persisted and I will have to delete everything but my desired one.
How would I get around this challenge, I can't really seem to find that particular use-case in the Core Data Programming Guide, which sort of also bugs me a bit, am I going against best practice here?
Thanks for any help given.