There is an easy but little known way to store many kinds of UIKit objects in CoreData without writing any code. It works for UIImage, UIColor, UIBezierPath, MKPlaceMark, NSDate, and any other class that conforms to the NSCoding protocol.
What you need to do is set the attribute type to Transformable.
That’s it!
Now can set UIImage objects directly into your NSManagedObject objects:
person.thumbnailImage = [UIImage imageNamed:@"defaultPortrait"]; anImageView.image = person.thumbnailImage;
Hi,
I tried this with MKPlacemark and couldn’t get it to work as described above. However if I leave out the name field then it works. Apparently this is the default value anyway. This blog post was very useful, thanks.
iOSBrett
Wow this is really helpful. I am wondering….I also noticed another option box to “Store in External Record File”
Anyone have experience with this? It may be the solution to Not storing images in the Core data. without a lot of coding.