I have CoreData in my app, with an Entry class, which contains an NSOrderedSet of Media classes.
I then have this code, for adding a new Media item to the NSOrderedSet:
-(void)addImage:(UIImage *)image isInPhotoLibrary:(BOOL)isInPhotoLibrary {
Media *media = [[Media alloc] init];
media.type = @"Image";
media.originalImage = UIImageJPEGRepresentation(image, 1.0);
media.isInPhotoLibrary = [NSNumber numberWithBool:isInPhotoLibrary];
[self addMediaObject:media];
}
Will this automatically save the changes, or will I have to do it myself. If so, will i then need to pass in a context to do this, or is there another way?
No it won’t.. If you want to save changes to Database in Core data you gotta call save function for that.. I assume
Mediais kind ofNSManagedObjectclass. To save the changes topersistent storeyou have to callsavemethod . Until then the changes are just temporary present on yourscratch board/ ManagedObjectContext.This is how I save changes: