将图像存储在Core Data中或作为文件? [英] Storing images in Core Data or as file?

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

问题描述

我有一组包含图像的数据。我想缓存这些数据。我应该将它们存储在文件系统或核心数据上?为什么?

I have set of data which contains images also. I want to cache this data. Should i store them on file system or on core data and why?

推荐答案

有两个主要选项:


  1. 将文件存储在磁盘上,然后将图像的路径存储在核心数据中

  2. 将二进制数据在核心数据中的图像

我个人更喜欢第一个选项,因为它允许我选择何时加载实际图像记忆。这也意味着我不必记住原始数据是什么格式;我可以使用路径 alloc / init 一个新的 UIImage object。

I personally prefer the 1st option, since it allows me to choose when I want to load the actual image in memory. It also means that I don't have to remember what format the raw data is in; I can just use the path to alloc/init a new UIImage object.

这篇关于将图像存储在Core Data中或作为文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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