Tejas Bharambe
Tejas Bharambe

Reputation: 682

Alternate to NSPersistentStoreUbiquitousContentNameKey key in core data in iOS 10.0

I am using two keys NSPersistentStoreUbiquitousContentNameKey and NSPersistentStoreUbiquitousContentURLKey to specify that persistent store has a given name and URL in ubiquity. But this keys are deprecated in iOS 10.0. So need to remove this deprecated api with alternate 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;
}

I have gone through the release notes for iOS 10.0 but not found any workaround for this. Is there any alternate to these keys?

Upvotes: 4

Views: 727

Answers (1)

Tom Harrington
Tom Harrington

Reputation: 70976

There is no alternative to these keys. These keys are used with Core Data's iCloud integration, which was deprecated as of iOS 10. All methods, variables, etc that work with it are now deprecated. There is no direct replacement. The iCloud integration will continue working (as well as it ever did) for now but could be shut down at some point.

Apple provides CloudKit, but it's not a direct replacement since it works differently. Using CloudKit wouldn't mean replacing these keys, it would mean redesigning your app. There's an open source framework called Ensembles that works something like Core Data with iCloud, which might be what you need.

Upvotes: 2

Related Questions