I have an array of UIImages that I want to store for easy access later. From what I've read I should save the references in Core Data and the images to disk. I have created a userImages attribute on my entity and set it to Transformable, and my image array is called userImages.
The next step is to do something like this:
NSFetchRequest * request = [[NSFetchRequest alloc] init];
[request setEntity:[NSEntityDescription entityForName:@"Item" inManagedObjectContext:context]];
[request setPredicate:[NSPredicate predicateWithFormat:@"itemId=%@",3]];
item = [[context executeFetchRequest:request error:&error] lastObject];
if (error) {
NSLog(@"error with request");
}
//Update the object
item.userImages = someArrayOfImageReferences;
error = nil;
if (![context save:&error]) {
NSLog(@"error");
}
But how do I construct someArrayOfImageReferences? Do I have to create another array of arbitrary image names like image1.png, image2.png, etc? Seems like there should be a better way.