iOS应用程式的核心资料,相片& iCloud

编程入门 行业动态 更新时间:2024-10-17 00:29:13
本文介绍了iOS应用程式的核心资料,相片& iCloud的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在开发一个应用程序,使用核心数据(使用UIManagedDocument)来存储我想要与iCloud同步的用户生成的数据。我也想在应用内同步用户使用相机拍摄的照片。

我读到在核心数据中存储实际照片不是一个好主意;而是更好地将照片存储在文件系统中,并将fileURL放在核心数据中。

使用此方法,当使用UIDocument在文件系统(文档文件夹)下存储照片时,建议采用什么方法? 我想过:

  • 对于每张照片,使用NSFileWrapper(包含实际映像和
  • 使用顶层NSFileWrapper,并为每张照片放置所有NSFileWrappers
  • 与#2类似,但只是将所有照片/缩略图直接放在顶级NSFileWrapper中
  • 哪种方法最适合与iCloud同步照片?并且有更好的方法吗?

    解决方案

    在这种情况下,最好的办法是让Core Data决定把它放在哪里。 p>

    打开您的Core Data模型GUI - 单击将保存您的二进制数据的属性 - 右侧有一个复选框,指示Core Data是否应该如果需要使用外部存储。选择它。

    就是这样。如果Core Data需要使用外部存储,它将这样做 - 你既不知道也不关心它决定什么。

    I'm developing an app that uses core data (with UIManagedDocument) for storing user-generated data that I would like to sync with iCloud. I also would like to sync photos that the user takes with the camera within the app.

    I read that it's not a good idea to store the actual photos within core data; rather it's better to store the photos in the file system and put the fileURL in core data.

    Using this method, what is the recommended approach when using UIDocument to store the photos in the file system (under the Documents folder)? I've thought about:

  • For each individual photo, use a NSFileWrapper(containing the actual image and thumbnail image), or
  • Use a top-level NSFileWrapper, and put all NSFileWrappers in it for each photo
  • Similar to #2, but just put all photos/thumbnails directly in the top-level NSFileWrapper
  • Which approach is better for syncing photos with iCloud? and are there better approaches?

    解决方案

    The best approach in this case is to let Core Data decide where to put it.

    Open your Core Data model GUI -- click on your attribute that will hold your binary data -- look to the right -- there is a check box that indicates if Core Data should use external storage if it wants. Select it.

    That's all. If Core Data needs to use external storage, it will do so -- you wil neither know nor care what it decides.

    更多推荐

    iOS应用程式的核心资料,相片& iCloud

    本文发布于:2023-11-27 23:25:43,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1640024.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:程式   相片   核心   资料   iOS

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!