问题标签 [nspersistentcloudkitcontainer]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
1594 浏览

ios - Disable CloudKit debugging logs

I am using a NSPersistentCloudKitContainer for the database in my iOS app. By default it seems to log all events to the console, I am assuming for debugging purposes. These messages look like this:

They are constant and are getting in the way of other debug messages, is there any way to disable them?

0 投票
2 回答
2623 浏览

core-data - NSPersistentCloudKitContainer: How to check if data is synced to CloudKit

I have implemented NSPersistentCloudKitContainer to get my data synced to CloudKit, I would like to know that the sync is finished and there is no other change pending to be synced.

When I tried reinstalling the app, I start getting my data back from CloudKit and it started printing certain logs in the console. It takes around 30 seconds to get all my data back from the CloudKit. Some of the logs mention about NSCloudKitMirroringDelegate. It looks like NSCloudKitMirroringDelegate knows about the remaining sync requests but I couldn't find any information about being sure that the sync is complete.

here are few logs which does show that NSCloudKitMirroringDelegate knows when sync is finished.

CoreData: CloudKit: CoreData+CloudKit: -NSCloudKitMirroringDelegate checkAndExecuteNextRequest: : Checking for pending requests.

CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _enqueueRequest:]_block_invoke(714): : enqueuing request: A2BB21B3-BD1B-4500-865C-6C848D67081D

CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate checkAndExecuteNextRequest]_block_invoke(2085): : Deferring additional work. There is still an active request: A3E1D4A4-2BDE-4E6A-8DB4-54C96BA0579E

CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate checkAndExecuteNextRequest]_block_invoke(2092): : No more requests to execute.

Is there any way to know that the data is synced completely? It is required for me to show certain UI to the user.

0 投票
5 回答
3314 浏览

core-data - NSPersistentStoreRemoteChangeNotification 没有被解雇

我正在尝试在我的 CoreData+CloudKit 项目中执行历史跟踪,该项目使用NSPersistentCloudKitContainer. 我一直在关注 Apple 的示例项目

我想在远程存储更新后执行某些任务。为此,苹果建议在应用程序的“签名和功能的后台模式”部分启用远程通知。

我已经为我的项目启用了历史跟踪,如 Apple 的示例项目所示。

我也注册了我的商店来监听商店的变化。

还添加了观察者来监听NSPersistentStoreRemoteChangeNotification

然而,没有NSPersistentStoreRemoteChangeNotification被解雇。为了确保我的实现没有错误,我只是在@objc func storeRemoteChange(_ notification: Notification)Apple 提供的示例代码中放置了断点,但我仍然看不到任何通知被触发并且没有断点被激活。

我已经了解在示例项目中完成的标签的重复数据删除,并尝试对其进行测试,但没有任何成功。这是 Apple 实施中的错误还是我缺少任何所需的设置?

0 投票
1 回答
116 浏览

swift - CKQueryNotification.recordID:无法识别的选择器发送到实例

我正在尝试设置静默推送通知以使用 CloudKit 在设备之间传播本地通知,但我无法理解为什么每次收到远程通知时我的应用程序都会崩溃。

在我尝试处理收到的通知之前,一切正常。尝试访问 didReceiveRemoteNotification 中的 CKQueryNotification 对象的 recordID 时发生崩溃。

我正在应用程序 didFinishLaunchingWithOptions 中注册远程通知。这是其余的代码:

在 didRegisterForRemoteNotification 中,我正在为记录类型 CD_Task 创建一个 CKSubscription。

在 DidReceiveRemoteNotification 内部,我将一个 CKQueryNotification 对象传递给一个函数来处理从 iCloud 接收到的远程通知:

最后,这里是 iCloudHandleNotification 函数代码:

编辑:

经过调查,似乎我得到的是 CKDatabaseNotification 而不是 CKQueryNotification——我应该如何指定我想要一个 CKQueryNotification?

0 投票
1 回答
383 浏览

swift - 您可以在多个应用程序之间使用 NSPersistentCloudKitContainer 共享数据吗?

所以我的问题就像标题中写的那样,如果你可以使用 NSPersistentCloudKitContainer 在不同的应用程序之间共享数据,比如你有一个不同的 iPad 应用程序、一个不同的 iPhone 应用程序和一个不同的 Mac 应用程序,如果可能的话,你会怎么做?提前致谢!

0 投票
1 回答
221 浏览

swift - 带有 NSPersistentCloudKitContainer 崩溃的 Mac 催化剂:EXC_BAD_INSTRUCTION(代码=EXC_I386_INVOP,子代码=0x0)

我的应用程序使用 NSPersistentCloudKitContainer,它在 iPhone 和 iPad 上运行良好。将它移植到 Mac (Catalyst) 后,我开始遇到 EXC BAD INSTRUCTION 崩溃,我无法绕开它。

我决定使用 Catalyst 从 WWDC 2019 移植到 MacOS Apple 的 NSPersistentCloudKitContainer 演示项目,但我遇到了同样的崩溃。

我还尝试开始一个新的简单项目,我使用 Catalyst 将它移植到 MacOS,并且它不会崩溃。所以,我的猜测是问题与新的 NSPersistentCloudKitContainer..

有人遇到同样的崩溃吗?任何指导将不胜感激。

这是崩溃日志:

0 投票
1 回答
325 浏览

swift - 使用 NSPersistentCloudKitContainer 时记录唯一性?

我已成功迁移我的应用程序以NSPersistentCloudKitContainer使用 CloudKit 同步其数据。

但是,我想知道我应该如何处理某些实体的唯一性。例如,假设一个User实体具有emailAddress需要唯一的属性。现在考虑两个设备创建User具有相同电子邮件地址的实例的情况。在我当前的实现中,没有任何东西强制执行唯一性,所以我最终在两个设备上都可以使用 2 个实例,只要它们得到同步更改。

目前,每当我假设它们是唯一的实体时,我都会检查它们是否真的是,如果不是,则合并它们,包括将一个实例的关系分配给另一个实例。合并后,我删除了“空”实例。虽然这似乎工作正常,但我也可以假设这可能会出错:当两个设备同时合并并最终删除不同的实例时,导致所有这些实例都被删除。

我应该如何处理这样的情况?

PS。我一直在寻找类似的问题,发现了一些类似的问题,但它们都与明确使用CKRecord. 由于我使用NSPersistentCloudKitContainer的是封装和简化 CloudKit 实现的 ,因此我没有使用那些“低级”类。

0 投票
1 回答
763 浏览

swift - 在运行时切换 iCloud 同步

我有一个 SwiftUI 应用程序,用户可以通过应用程序内购买购买一些高级功能。其中一项功能是在更多设备上进行 iCloud 同步。我正在使用 CoreData 来保存用户数据。我的持久化容器:

我的问题是当用户购买订阅时如何打开/关闭云同步。我不希望用户必须重新启动应用程序。我还希望用户可以在应用内设置中切换此设置。

谢谢

0 投票
4 回答
1448 浏览

ios - CoreData 使用 NSBatchInsertRequest

我正在尝试CoreData根据NSBatchInsertRequestWWDC 2019 ( https://developer.apple.com/videos/play/wwdc2019/230/ ) 插入字典数组。insertResult 为 nil,我的 CoreData 为空。

这是我在控制台中收到的错误:

0 投票
1 回答
348 浏览

core-data - 如何检测 iOS App 是由特定用户(不是在特定设备上)首次启动的?

我在我的应用程序(iOS 13+)(swift)中使用我的应用程序 cloudKit + 核心数据。

无论设备如何初始化一些默认数据,我都无法弄清楚如何检测应用程序的第一次运行。

有很多帖子如何检测 iOS 应用在特定设备上的首次启动——这很容易。我找不到检测特定用户首次运行应用程序的解决方案,或者换句话说 - 如果在用户的 iCloud 中确实存在具有特定容器标识符的初始化容器。

如果用户之前已经在另一台设备上使用过该应用程序,那么在新设备上首次启动时,将与 iCloud 同步,应用程序将使用用户的数据。但是如果用户之前从未使用过该应用程序,我需要初始化一些数据。

我正在寻找如何处理它几个小时的线索,找不到任何相关的东西。任何想法?

提前感谢您的帮助。