开发者

Store image in core data

开发者 https://www.devze.com 2023-02-14 13:09 出处:网络
I want to store image for every employee while updating their records. How can I do that? I have a dictionary storing name, id and department of employe开发者_开发技巧es. Now i want the image to be s

I want to store image for every employee while updating their records. How can I do that?

I have a dictionary storing name, id and department of employe开发者_开发技巧es. Now i want the image to be saved together.


Core Data supports the "Binary Data" type - When you define a model with a Binary Data field, it creates your model class with an NSData field. You can move an image into the NSData field, and CoreData will save it for you.

You can then use UIImage initWithData: to load the image from the NSData field.

Hope this helps !


For strore image as CoreDate attribute need:

  1. Add transformable attribute and set transformer with own class
  2. Implement ImageToDataTransformer

See here for an example http://www.iphonedevsdk.com/forum/181656-post3.html

0

精彩评论

暂无评论...
验证码 换一张
取 消