使用核心数据与每个实体的许多图像? [英] Using Core Data with many images per entity?

查看:128
本文介绍了使用核心数据与每个实体的许多图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Core Data的新手,我正在开发我的第一个个人iOS应用程式。



我有一个实体,叫它 Car ,它有一个缩略图以及其他图片相关联。使用 ASIHTTPRequest JSONKit 将数据同步到在线服务。该应用程序不需要创建新的 Car ,只需显示它们。



100kB,所以我可以存储为blob数据在 Car 实体。



但是我不知道应该存储其他多个图像吗?



图像将是大约800kB到1MB每个使用这样存储在Core Data存储似乎不推荐。 p>

我可以想到的唯一选项是:




  • 存储每张照片的网址在另一个实体 CarImage 中,并依靠 ASIHTTPRequest 的缓存。

  • 创建一个文件夹结构,并将每个图像保存到相应的 Car 的文件夹中,并保留对 CarImage 实体



因为数据已同步,所以 Car s被删除,因此文件夹中的图像也必须被删除。我可以很快看到这种情况。



我很感激任何建议。谢谢。

解决方案

我会选择您的第一个选项。



关于必须被删除的图像:这不是由ASIHTTPRequest的缓存自动处理,一旦他们到期?至少这是我希望从缓存...


I'm new to Core Data and I'm working on my first personal iOS app.

I have an entity, lets call it Car, which has a thumbail as well as a gallery of other images associated with it. The data is synced to an online service using ASIHTTPRequest and JSONKit. The app doesn't need to create new Car's, just display them.

The thumbnail could be around 100kB so I may store that as blob data within the Car entity.

However I'm not sure how I should store the other multiple images?

The images would be around 800kB to 1MB each using so storing them in the Core Data store doesn't seem to be recommended.

The only options I can think of are:

  • Store the url of each photo within another entity CarImage and rely on ASIHTTPRequest's cache.
  • Create a folder structure and save each image into it's corresponding Car's folder and keep references to the file path in the CarImage entity

Because the data is synced, there is the potential for Car's to be deleted, so images in folders would have to be deleted as well. I can see this getting out of hand pretty quickly.

I would appreciate any advice. Thanks.

解决方案

I'd take your first option.

Regarding the images that would have to be deleted: isn't that taken care of automatically by ASIHTTPRequest's cache, once they expire? At least that's what I'd expect from a cache...

这篇关于使用核心数据与每个实体的许多图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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