简体   繁体   English

在iOS中存储图像的最佳方式

[英]Best way to store images in iOS

I was wondering if anyone could suggest the best way for me to store images for my app. 我想知道是否有人可以建议我为我的应用程序存储图像的最佳方式。

I want to be able to provide an XML update functionality that will allow the user to update their app with a new set of images. 我希望能够提供XML更新功能,允许用户使用一组新图像更新他们的应用程序。 I was wondering what the best way to do this was as i need to read and write to the store location. 我想知道最好的方法是什么,因为我需要读取和写入商店位置。 Is storing them in a sqlite database the best way or am i able to use the filesystem to do this without the chance of the iPhone deleting any of the downloaded images? 是以最好的方式将它们存储在sqlite数据库中,还是我能够使用文件系统来执行此操作而不会删除任何下载的图像?

Thanks 谢谢

You can write to the filesystem, every app in iOS is sandboxed and has access to his own documents folder. 您可以写入文件系统,iOS中的每个应用程序都是沙箱,并且可以访问自己的文档文件夹。

I would suggest to write on filesystem and only save the urls on the database as that is more performant than saving blobs on a database. 我建议在文件系统上编写,只保存数据库中的URL,因为这比在数据库上保存blob更有效。

Apple has a good write up about the iOS filesystem. Apple对iOS文件系统有很好的了解

Alternatively you could implement a solution using SQLite, Apple mentions it in the: Large Data Objects (BLOBs) section here: 或者你可以使用SQLite实现一个解决方案,Apple在这里提到它:大数据对象(BLOB)部分:

https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CoreData/Articles/cdPerformance.html#//apple_ref/doc/uid/TP40003468-SW5 https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CoreData/Articles/cdPerformance.html#//apple_ref/doc/uid/TP40003468-SW5

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM