My app uses a single document (UIDocument) to contain its information and never closes it while the app is open. I have implemented iCloud connectivity to save the file so I can share it across devices. When using the simulator (iOS7), I can open the document and save to it. If I quit the App in the simulator, I can still open the iCloud document and work with it when I relaunch.
I'm testing on an iPad (iOS7) and the simulator to work out the updates between devices. I can successfully open the iCloud document (saved by the simulator) and see everything properly on the iPad. However, if I quit the App on the iPad and relaunch it, I get success = NO and Document State = UIDocumentStateSavingError in my openWithCompletionHandler. I captured the error in the handleError method and found this:
Error
Domain=NSCocoaErrorDomain
Code=257 "The operation couldn’t be completed. (Cocoa error 257.)"
UserInfo=0x14650360 {NSFilePath=/private/var/mobile/Library/Mobile Documents/2A9S2V8BH4~com~mishnookasoftware~selists/Lists.archive, NSUnderlyingError=0x1462b590 "The operation couldn’t be completed. Operation not permitted"}
This appears to be a permission denied error. I double checked the certificate to ensure iCloud was enabled for the App, and it is. I have tested to see if changes made on my iPad are pushed to iCloud, by quitting the App in the simulator and relaunching it to see the updates.
I do close the iCloud document in the App Delegate's applicationWillTerminate method ([iCloudListDocument closeWithCompletionHandler:nil];). I'm wondering if the file is not getting properly closed and thus cannot be reopened upon relaunch.
I have searched StackOverflow and could not find anything to help my situation. Any help is greatly appreciated.