YasBES
YasBES

Reputation: 2325

Core Data save UIImage

I have a Core Data in this database should I save images, so how can do to save an image that is just takes URL ... Example please

Upvotes: 2

Views: 1936

Answers (1)

GorillaPatch
GorillaPatch

Reputation: 5057

Large images (>100 kb) should not be saved in CoreData, as it would really increase your managed object's memory footprint.

For these images I would save the path in CoreData as a string or an URL and then load the image if you need it.

In principle you can save anything as an attribute in a CoreData entity if it can be archived into a NSData object. There are examples in the CoreData documentation of how to save a UIColor to the database which uses exactly this technique.

Check out the CoreRecipes sample code in which an image is attached to each recipe. This is basically the same thing you want to do.

Upvotes: 5

Related Questions