在Objective-C中使用NSPersistentCloudKitContainer

问题描述

我正在使用一个Objective-C / Swift混合项目,我正在尝试更新该项目以使用NSPersistentCloudKitContainer将我的本地数据存储与云同步,但我似乎找不到任何示例。到目前为止,我已经更新了AppDelegate.m,以包括新的Objective-C“使用CloudKit”项目随附的股票代码

- (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:@"CNS_Test_CD"];
        [_persistentContainer loadPersistentStoresWithCompletionHandler:^(NSPersistentStoreDescription *storeDescription,NSError *error) {
            if (error != nil) {
                // Replace this implementation with code to handle the error appropriately.
                // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application,although it may be useful during development.
                
                /*
                 Typical reasons for an error here include:
                 * The parent directory does not exist,cannot be created,or disallows writing.
                 * The persistent store is not accessible,due to permissions or data protection when the device is locked.
                 * The device is out of space.
                 * The store Could not be migrated to the current model version.
                 Check the error message to determine what the actual problem was.
                */
                NSLog(@"Unresolved error %@,%@",error,error.userInfo);
                abort();
            }
        }];
    }
}

return _persistentContainer;

}

现在,我正在尝试找出同步使用数据存储的Objective-C类和Swift类的下一步。根据我在网上找到的各种Swift教程,所有的复选标记均已打勾,但我正在寻找Objective-C的下一步。在我以前的Core Data经验中,我从未使用过容器容器。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)