使用 tesflight 应用程序时如何读取日志?应用程序没有崩溃。我在设备中找不到任何崩溃日志。还有其他想法吗?如何检查 CloudKit 中的 ie 是否有问题,但仅在 testflight 应用程序中而不是在调试模式下运行时检查?
有没有办法通过 CloudKit 获取 iCloud Notes?我查看了文档:
https://developer.apple.com/documentation/cloudkit
但没有找到如何访问 Notes 数据的方法。
func application(_ application: UIApplication, userDidAcceptCloudKitShareWith cloudKitShareMetadata: CKShare.Metadata) {...}
Run Code Online (Sandbox Code Playgroud)
在指向共享 cloudkit 记录的链接上单击“确定”后不会被调用。应用程序会打开,但这个函数(应该被调用)不会。
func application(_ application: UIApplication, userDidAcceptCloudKitShareWith cloudKitShareMetadata: CKShare.Metadata) {
print("you accepted something")
let acceptShareOperation: CKAcceptSharesOperation = CKAcceptSharesOperation(shareMetadatas:[cloudKitShareMetadata])
//acceptShareOperation.qualityOfService = .userInteractive
acceptShareOperation.perShareCompletionBlock = {meta, share,
error in
print("share was accepted")
}
acceptShareOperation.acceptSharesCompletionBlock = {
error in
/// Send your user to where they need to go in your app
print("share accepted completion block!")
}
CKContainer(identifier: cloudKitShareMetadata.containerIdentifier).add(acceptShareOperation)
}
Run Code Online (Sandbox Code Playgroud)
预期结果:至少看到“你接受了某些东西”这一行打印在控制台上。
更新:恢复到 IOS11.3 不起作用。
更新:我下载了一个有人使用 …
我刚刚使用新的 iOS 13 完成了 CoreData+CloudKit 的设置NSPersistentCloudKitContainer。它工作得非常好,因为我可以使用自动生成的 CoreData 类进行属性访问和本地存储,并NSPersistentCloudKitContainer自动同步设备之间的更改。我遇到的问题是收到远程更改的通知。我检查了苹果的文档和这个国家,你告诉NSPersistentCloudKitContainer的NSPersistentStoreDescription您希望它发送通知,然后将其他对象注册为该通知的观察者。我已经这样做了并添加了一个测试方法来显示检测到远程更改的时间。测试方法生成的警报永远不会生成,但是如果我杀死应用程序并重新打开它,更改就会立即出现。所以我相信远程更改正在同步并集成到本地 CoreData 存储中,但通知不起作用。我已将Background Modes权利添加到我的目标并选择了Remote notification模式。代码如下。任何帮助将不胜感激!
设置发送通知的选项:
- (NSPersistentCloudKitContainer *)persistentContainer {
// The persistent container for the application. This implementation creates and returns a container, having loaded the store for the application to it.
@synchronized (self) {
if (_persistentContainer == nil) {
_persistentContainer = [[NSPersistentCloudKitContainer alloc] initWithName:@"<redacted>"];
[_persistentContainer loadPersistentStoresWithCompletionHandler:^(NSPersistentStoreDescription *storeDescription, NSError *error) {
if (error != nil) {
// ...
}
else …Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,我将数据与核心数据一起存储。最近我发现了 Apple 在 WWDC19 中引入的新功能,它允许核心数据与 CloudKit 一起使用。我刚刚为我的应用程序启用了 cloudKit,并使用了 NSPersistentCloudKitContainer 而不是 NSPersistentContainer,一切都设置好了!我的所有数据都在 ios 设备之间共享。这与 NSPersistentContainer 类似,但它会在 icloud 服务器上发送更改的副本,因此始终存在本地数据缓存。
现在我想从我的 Apple Watch 配套应用程序访问这些数据,但不是所有的数据,只有一个特定的实体!那我怎么能这样做呢?我尝试使用属性检查器设置在两个目标之间共享的 NSPersistentCloudKitContainer,但看不到任何数据。我可以在 cloudKit 仪表板中看到有来自 watchOS 的请求,但 watch 没有获得任何数据。
但是如果我将手表中的实体保存到核心数据中,我只能从手表中获取它。我的结论是两者都没有将数据存储在同一个地方。那么我该如何解决呢?已经有使用相同的 NSPersistendCloudKitContainer。
两个目标之间共享的容器:
import Foundation
import CoreData
public class CoreDataContainer {
lazy var persistentContainer: NSPersistentContainer = {
/*
The persistent container for the application. This implementation
creates and returns a container, having loaded the store for the
application to it. This property is optional since there are legitimate
error conditions that could …Run Code Online (Sandbox Code Playgroud) 我遇到以下场景,我从 JSON 文件解析对象并将它们存储到我的核心数据存储中。现在我正在使用NSPersistentCloudKitContainer,当我在不同的设备上运行该应用程序时,它还会解析 JSON 文件并将对象添加到核心数据中。这会导致重复的对象。
现在我想知道是否有:
我正在为 MacOS 编写一个应用程序,主要功能是将数据同步到 iCloud。我已经完成的所有工作就是 - 打开 Core-Data 和 CloudKit 选项的项目, - 创建一个模型和一些基本例程,通过将文件导入到应用程序来创建模型。
由于这是一个大文件,因此我在单独的线程/调度新队列中执行所有操作。当我调试应用程序时,将数据保存到本地数据库工作正常,然后当应用程序失去焦点时数据会同步到云,我不得不说它有效,我可以通过查询 CloudKit 仪表板中的数据来说明这一点。但是,当我开始导入文件以及在导入过程中我将切换到其他应用程序时,同步数据存在问题。导入完成后,我看到数据存储在本地,但无法同步到云端。相反,我在控制台中看到以下错误:
CoreData: 调试: CoreData+CloudKit: -PFCloudKitThrottledNotificationObserver noteRecievedNotification:: : 得到: NSApplicationWillBecomeActiveNotification - 0 CoreData: 调试: CoreData+CloudKit: -PFCloudKitThrottledNotificationObserver noteRecievedNotification:: : 得到: NSApplicationDidBecomeActiveNotification - 1 CoreData: CloudKit: CoreData+CloudKit: -PFCloudKitThrottledNotificationOb服务器注释已收到通知: : - 已经安排了一个块来响应“NSApplicationDidBecomeActiveNotification”,此后有 2 个通知。CoreData: debug: CoreData+CloudKit: -[PFCloudKitThrottledNotificationObserver noteRecievedNotification:]_block_invoke(49): : 为“NSApplicationWillBecomeActiveNotification”执行“AppActivateObserver”块,清除 2 次迭代。CoreData: CloudKit: CoreData+CloudKit: -NSCloudKitMirroringDelegate _scheduleAutomatedExportWithLabel:activity:completionHandler:: - 开始自动导出 - AppActivationExport: (null) CoreData: CloudKit: CoreData+CloudKit: -NSCloudKitMirroringDelegateexecuteMirroringRequest:error:: : 要求执行请求:41AA55D5- F8A9-4EA9-A12A-9CA05775EC03 CoreData: CloudKit: CoreData+CloudKit: -NSCloudKitMirroringDelegate _scheduleAutomatedImportWithLabel:activity:completionHandler:: - 开始自动导入 - AppActivationImport - 响应活动:(null) CoreData: …
在视图顶部显示 UICloudSharingController 时,它会显示屏幕,当我选择消息选项向我想与之共享的人发送消息时,它会提供一个带有“上传”消息的旋转轮,并消失 - 附加
.
但是,当我转到 cloudkit 仪表板时,根记录已共享。但我不能与特定的人分享。是因为它共享了全局吗?我该如何解决?
self.shareInfraRecord(zoneID: appDelegate.privateContactZoneID, completion: { (status) in
if ( status == false) {
return
}
})
func shareInfraRecord(zoneID: CKRecordZone.ID, completion: @escaping(Bool) -> Void) {
if let rootRecord = self.rootRecord {
if self.rootRecord?.share == nil {
let sharingController = UICloudSharingController { (controller, preparationHandler: @escaping (CKShare?, CKContainer?, Error?) -> Void) in
let shareID = CKRecord.ID(recordName: UUID().uuidString, zoneID: zoneID)
var share = CKShare(rootRecord: rootRecord, shareID: shareID)
share[CKShare.SystemFieldKey.title] = Cloud.ShareInfrastructure.ContactShareTitleKey as CKRecordValue?
share[CKShare.SystemFieldKey.shareType] = Cloud.ShareInfrastructure.ContactShareTypeKey as …Run Code Online (Sandbox Code Playgroud) 我面临以下问题:
当用户决定删除设置内的所有 iCloud 数据时,所有本地核心数据保存也会自动删除。
经过一些调试后,我发现这正是在我第一次初始化NSPersistentCloudKitContainer. 那么合并会以某种方式重置本地数据吗?
我还使用NSPersistentCloudKitContainer. 我也可以观察到这种行为,这让我得出结论,这是默认发生的?
任何帮助将不胜感激。如果您愿意,我可以告诉您详细信息,我只是不知道应该包括什么。
这可能是故意的吗?
据称,这一操作还将删除该 iPhone 上存储的所有数据。
但如果用户只想清理一些 iCloud 空间怎么办?
通过测试许多实际应用程序 - 其中一部分也显示了丢失所有本地数据的行为。但也有相当数量的应用程序在重置后保留本地数据。
我还用苹果自己的 Clips 应用程序对其进行了测试。所有本地数据也消失了。
我们的每个数据行都包含一个唯一的uuid列。
以前,在采用CloudKit之前,uuid列有一个唯一的约束。这使我们能够防止数据重复。
现在,我们开始将 CloudKit 集成到我们现有的 CoreData 中。这种唯一的约束被删除。下面的用户流程,会造成数据重复。
uuid生成具有预定义的预定义数据。uuid生成具有预定义的预定义数据。uuid!:(我想知道,我们有没有办法防止这种重复?
在第 8 步中,我们希望有一种方法可以在写入 CoreData 之前执行此类逻辑
检查CoreData中是否存在这样的uuid。如果没有,则写入 CoreData。如果没有,我们将选择更新日期最新的数据,然后覆盖现有数据。
我曾经尝试将上述逻辑插入https://developer.apple.com/documentation/coredata/nsmanagementobject/1506209-willsave。为了防止保存,我正在使用self.managedObjectContext?.rollback(). 但它只是崩溃了。
您知道我可以使用哪些可靠的机制来防止 CoreData CloudKit 中的数据重复吗?
我们正在使用以下 CoreData 堆栈
class CoreDataStack {
static let INSTANCE = CoreDataStack()
private init() {
}
private(set) lazy var persistentContainer: NSPersistentContainer = {
precondition(Thread.isMainThread)
let container = …Run Code Online (Sandbox Code Playgroud)