I have a short setup process in my app and I create an NSManagedObject to store name and other details of an individual, however during this setup I don't want to save the object until the user presses 'Done' right at the end of the setup (just incase they cancel the setup for whatever reason).
So is it possible to keep hold the object holding my info for a short time until the end of the setup process without actually saving it into CoreData?
You can also use
NSEntityDescription *ed = [NSEntityDescription entityForName:@"YourManagedObject" inManagedObjectContext:managedObjectContext];
YourManagedObject *obj = [[[YourManagedObject alloc] initWithEntity:ed insertIntoManagedObjectContext:nil] autorelease];
to create the managed object without inserting it into your context.
You can do that later by calling [managedObjectContext insertObject:obj];
.
When you are dealing with CoreData, all add/modify/delete actions occur in the NSManagedObjectContext - but changes are not persisted to disk until you call 'save' on that context.
So the answer is yes - this is the behavior you should already be getting. If you are adding or modifying the properties of NSManagedObjects, these changes are kept in the memory of the context, but are not being saved to disk until you actually call 'save'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With