Search code examples
iosobjective-cswiftwatchkitapple-watch

WatchKit 2.0 and iPhone shared coredata


everyone.

I've started my work on a Watch Kit app with. With WatchKit 1 it was pretty easy to access the coredata database in the shared folder. But when I've updated to xcode 7, watch kit 2.0 and swift 2.0 it appears that AppleWatch and iPhone has different app group shared folder address. And following code

NSURL *storeURL = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:BMCoreDataConstants.groupIdentifier];
storeURL = [storeURL URLByAppendingPathComponent:BMCoreDataConstants.sqliteStoreNameWithExtension];

Returns different url on the iPhone and AppleWatch.

Please advise if you know what is the best way now to fetch data from the parent app's coredata?


Solution

  • I've found perfectly explaining WWDC video here:

    https://developer.apple.com/videos/wwdc/2015/?id=713

    Feel free to see it if you have got same question.