I have been following these instructions to help integrate iCloud support with CoreData and I am getting some errors.
I have this in my AppDelegate:
For me, I found addPersistentStoreWithType
always returns nil
in my case. So the persistent store wasn't created successfully.
Then, I print the storeURL
~/Library/Developer/CoreSimulator/Devices/1F8C6299-1F80-4212-9FE2-CA33BD365851/data/Containers/Data/Application/9CA7B7BB-A835-4BC2-B12D-23B84D420F91/Library/Documentation/my-database.sqlite
This is a directory in which we can't write data. So I checked my code and found a silly mistake.
I should use NSDocumentDirectory
instead of NSDocumentationDirectory
. Code completion in Xcode offers the documentation directory before the document directory enum.
When I used
NSDocumentationDirectory
, NSPersistentStoreCoordinator
always tried to create the persist store in .../Library/Documentation/my-database.sqlite
, which is an invalid path.
.../Documents/BeeLocation.sqlite
.