Creating iOS 5 Apps Discussion > Page 437 - Chapter 7 app for iCloud not working
On the UIManagedDocument version, you shouldn't see the individual files listed in the iCloud storage. I did this deliberately--otherwise it just lists out all the transaction logs independently--and we definitely don't want users to delete one or two of these and put the database in a bad state.. You can always open and examine the iCloud container in code if you want to see the contents.
It's really easy to get the iCloud container into a bad state during development (especially when using Core Data). It might be handy to have a bit of code that can clear out the iCloud container commented out in your app. Then if things go bad, you can uncomment it and clean everything out. Kill the app. Comment it again and move forward. Use something like this:
[coordinator
coordinateWritingItemAtURL:ubiquitousURL
options:NSFileCoordinatorWritingForDeleting
error:nil
byAccessor:^(NSURL *newURL) {
[[NSFileManager defaultManager]
removeItemAtURL:newURL error:nil];
}];
This has to be called after you call URLForUbiquityContainerIdentifier:, and you should use the URL returned by that method for ubiquitousURL.
In particular, when you delete the document from iCloud storage (using either System Preferences on the Mac or Settings on an iOS device), it does not clean out the iCloud container. Nor does deleting the app from the device. In fact, the only way to clean out the iCloud container is to do it in code. This can be particularly bad when using Core Data, since the transaction logs will linger behind, and they can put the app in a bad state.
The Chapter 7 code from the book seems to work fine here. If you're having trouble running it, do the following steps:
1) Delete the apps data from iCloud storage.
2) Delete the app from all the devices.
3) On every device, delete the iCloud container in code.
4) Try cleaning and rebuilding the app, then running it on one device. Make sure the document is saved into iCloud storage (check in Settings or System Preferences).
5) Run the app on two devices and test the syncing.
My sample code should do step 3 automatically every time you've done steps 1 and 2--but you may want to make sure the container is explicitly cleared out if you're still having trouble.
I hope this helps.

As of the end of chapter 7, Health Beat's iCloud integration is not working. Some observations...
1. Data entered on my iPhone is not syncing to/from my iPad. They seem to independently work fine. Just the iCloud integration is not working. Yet, in my iCloud storage on any of my Macs, I only see one file for this app.
2. My iCloud storage filename for this app is Unknown (I recall it had a specific name in the chapter 6 version, although I am encountering problems now trying to run that version, see below).
3. The download source code app is also not working for iCloud integration, either, with the same above observations.
4. After deleting the app and iCloud storage, and then build & running it from Xcode on a device, subsequently running the app on that (or any) device independently (i.e., not launched from Xcode, the Unable to Save Changes label is persistently displayed.
5. My chapter 6 version definitely worked fine prior to commencing with chapter 7.
6. When I restore to my chapter 6 version and try to run it on a device (and also deleting the app and any iCloud storage), I get an NSInternalInconsistencyException error, 'An error occurred while trying to instantiate our history"
7. When I try to run the download source code app for chapter 6 version on a device (and also deleting the app and any iCloud storage), I get an NSInternalInconsistencyException error, 'An error occurred while trying to instantiate our history"
I will email you my project. Please advise.
Thanks