In my iCloud-based app, I noticed that if a crash were to occur while a UIDocument is open (and has not yet been closed), the status of the document sometimes becomes UIDocumentStateSavingError
and it never opens successfully again.
When I run [UIDocument openWithCompletionHandler:]
after this, the document never opens, returning NO
for success
and 5 (UIDocumentStateClosed
and UIDocumentStateSavingError
) for documentState
.
On iOS 5, I also observed that NSMetadataQueryDidUpdateNotification
is constantly being called (every second) until the file is deleted and the app is restarted. This causes additional usability problems in the app.
One more thing, on developer.icloud.com I noticed that the file is showing a second, conflicted version existing. This conflict isn't found on any of my devices, though, not even if the app is restarted or reinstalled.
What do I do to get the UIDocument to open normally?
Here is what I tried so far:
Checking
[NSFileVersion unresolvedConflictVersionsOfItemAtURL:]
for conflicts and removing all older version using[NSFileVersion removeOtherVersionsOfItemAtURL:]
.Calling
[[NSFileManager defaultManager] evictUbiquitousItemAtURL:]
before calling[UIDocument openWithCompletionHandler:]
to re-download the file to the device.Downloading the main and conflicted versions from developer.icloud.com to see if any of them are corrupt or partial files. Both open fine.
Banging my head against my desk. Preliminary results are unsuccessful.