Loading images from AppBundle vs. CoreData

寵の児 提交于 2019-12-12 04:38:32

问题


I'm making a catalog where the cells in my collection view will be either an image with a label or a pdf. There will be many collections and they themselves will be static. I want the user to be able to save the cells he likes and view them in his own custom view.

1) I could to store the image as data in Core Data.

2) I could just include the image in my App Bundle and load the image from there every time my app starts.

I've got it into to my head that reading data from a Core Data Store would give me more options when building my app as well as offer some boost in performance as opposed to reading it from the app bundle. Is that true? Keeping in mind of course that most of the data is static.

It seems inefficient to have images both serialized images in my app bundle and the pure data as well.

I think I'd rather have it all in the store but they have to be loaded from the bundle at some point in code right?

I'd love to know how other developers do it.


回答1:


Now in Core Data there is an "allows external storage" option for binary data, which basically means if your file is bigger than 1 MB it will be stored automatically outside of your database, and you have to do nothing differently. In my opinion that's the way to get the best of both worlds, increased performance + automatization + fast queries (although they are slower than usual when you allow external storage, but still faster than doing it yourself)



来源:https://stackoverflow.com/questions/15800589/loading-images-from-appbundle-vs-coredata

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!