Yemey
Yemey

Reputation: 31

how to sync core data icloud with ios and macOs app

I'm developping an iPad application that uses CoreData with iCloud. It works great! I'm able to open ~/Library/Mobile Documents" with the folder that matches my Team ID and iCloud container. I'm making also a macOS app that needs to access the iCloud. In macOS app, I added the iOS app container ID. So i have two container ID: ca.company.MacContainerID and ca.company.IPadContainerID which works for iPad app.

When i execute the following code in MacOS app, URLForUbiquityContainerIdentifier: returns nil.

NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *containerID =  @"A1B2C3E4F5.ca.company.IPadContainerID";
NSURL *url = [fileManager URLForUbiquityContainerIdentifier:containerID];    
url is nil

I don't know what to do to access to iCloud with core data inside from iPad app. Do you have an idea ?

Upvotes: 3

Views: 816

Answers (2)

Yemey
Yemey

Reputation: 31

I found the solution! I was building the Mac application with an iOS provisionning file. So i put a Mac provisioning and it works; URLForUbiquityContainerIdentifier return me a non nul value.

Upvotes: 0

Mundi
Mundi

Reputation: 80271

It must be a problem with your containerID. Did you double-check the ID string?

Upvotes: 0

Related Questions