Core Data – Storing Images (iPhone) [closed]

The rule for storing image data in Core Data is as follows:

  • < 100 kb store in the related entity (person, address, whatever).
  • < 1 mb store in a separate entity on the other end of a relationship to avoid performance issues.
  • 1 mb store on disk and reference the path in your Core Data store.

You can use the transformable data type to store the NSImage directly into Core Data. In fact you can use the transformable data type to store anything that implements the NSCoder protocol.

Personally I would not convert it to a CGImageRef as you can lose a lot of information that way.

Leave a Comment