gpt4 book ai didi

iphone - 使用新的外部存储标志将 UIImage 存储在 Core Data 中

转载 作者:行者123 更新时间:2023-12-03 18:18:44 25 4
gpt4 key购买 nike

我知道UIImage在核心数据中的存储已经讨论了很多,例如here ,但那是ios5之前的事情。现在我们有了外部存储标志,你们认为将 UIImage 直接存储在实体中、作为单独的实体还是仍然存储在磁盘上是个好主意吗?

Here是解释外部存储选项的来源。

最佳答案

Core Data Release Notes for iOS 5.0

When enabled, Core Data heuristically decides on a per-value basis if it should save the data directly in the database or store a URI to a separate file which it manages for you. You cannot query based on the contents of a binary data property if you use this option.

从你的链接External Binary Data ,启发式似乎是

Objects that are smaller than 1MB are stored in the database. For objects that are larger, an external file is created and the database just stores a reference to it.

因此以下建议仍然有效:CoreData : store images to DB or not?

  • < 100kb store in the same table as the relevant data
  • < 1mb store in a separate table attached via a relationship to avoid loading unnecessarily
  • 1mb store on disk and reference it inside of Core Data

该标志将 Core Data 设置为遵循该建议,并自动将 >1MB 的图像存储为单独的磁盘文件。

关于iphone - 使用新的外部存储标志将 UIImage 存储在 Core Data 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7924840/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com