将图像存储在核心数据中 [英] store image in core data

查看:108
本文介绍了将图像存储在核心数据中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为每个员工存储图像,同时更新其记录。我该怎么办?
我有一个字典存储的名称,id和部门的员工。



请帮助



Dipanjan

$ b $核心数据支持二进制数据类型 - 当您使用二进制数据字段定义模型时,它将使用NSData字段创建模型类。您可以将图像移动到NSData字段,CoreData将为您保存。



然后可以使用UIImage initWithData:从NSData字段加载图像。 / p>

希望这有助于!


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 employees. Now i want the image to be saved together.

Please help

Dipanjan

解决方案

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 !

这篇关于将图像存储在核心数据中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆