gpt4 book ai didi

ios - 替代 iOS 10.0 核心数据中的 NSPersistentStoreUbiquitousContentNameKey 键

转载 作者:搜寻专家 更新时间:2023-10-30 20:23:56 25 4
gpt4 key购买 nike

我使用两个键 NSPersistentStoreUbiquitousContentNameKey 和 NSPersistentStoreUbiquitousContentURLKey 来指定持久性存储具有普遍存在的给定名称和 URL。但此键在 iOS 10.0 中已弃用。因此需要使用备用 api 删除这个已弃用的 api。

-(NSPersistentStoreCoordinator *)persistentStoreCoordinator
{
//Return if the persistance store exists.
if (__persistentStoreCoordinator != nil) {
return __persistentStoreCoordinator;
}

__persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel: [self managedObjectModel]];
NSPersistentStoreCoordinator *psc = __persistentStoreCoordinator;

NSMutableDictionary *options = [NSMutableDictionary dictionary];

[options setObject:iCloudEnabledAppID forKey:NSPersistentStoreUbiquitousContentNameKey];
[options setObject:iCloudLogsPath forKey:NSPersistentStoreUbiquitousContentURLKey];
[options setObject:NSFileProtectionComplete forKey:NSPersistentStoreFileProtectionKey];

[psc lock];

return __persistentStoreCoordinator;
}

我已经阅读了 iOS 10.0 的发行说明,但没有找到任何解决方法。这些 key 是否有替代品?

最佳答案

这些键别无选择。这些 key 与 Core Data 的 iCloud 集成一起使用,从 iOS 10 开始不推荐使用。所有与之一起使用的方法、变量等现在都已弃用。没有直接替代品。 iCloud 集成现在将继续工作(和以往一样),但可能会在某个时候关闭。

Apple 提供 CloudKit,但它不是直接替代品,因为它的工作方式不同。使用 CloudKit 并不意味着要替换这些 key ,而是意味着要重新设计您的应用程序。有一个名为 Ensembles 的开源框架其工作方式类似于 Core Data with iCloud,这可能正是您所需要的。

关于ios - 替代 iOS 10.0 核心数据中的 NSPersistentStoreUbiquitousContentNameKey 键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47137659/

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