In order to test conflicts, I've been saving two different versions of the same document on two devices. On both devices I would then be able to look at the currentVersionOfItemAtURL
to see the 'winning' version - which was the same on both devices - and the otherVersionsOfItemAtURL
or removeOtherVersionsOfItemAtURL
to see the others.
However I now seem to have got a document in a weird state, where currentVersionOfItemAtURL
is different on the two devices, and there are no otherVersionsOfItemAtURL
or removeOtherVersionsOfItemAtURL
. Using getResourceValue:forKey:
with NSURLUbiquitousItemHasUnresolvedConflictsKey
reports that the URL has unresolved conflicts, but I've no way of seeing them.
What does it mean when a URL reports true for NSURLUbiquitousItemHasUnresolvedConflictsKey but there are no other versions of the URL? Is this a case I need to handle in a production app?
I followed the Apple sample code for resolving conflicts, but discovered when testing on iOS8 with the (old) Documents and Data store (not iCloud Drive) that setting the
NSFileVersion
propertyresolved = TRUE
was not sufficient.setResolved
would sometimes fail.The solution was to call
removeAndReturnError
on the result onunresolvedConflictVersionsOfItemAtURL
. The documentation says (my emphasis): "For any versions you no longer need, call theremoveAndReturnError:
method ofNSFileVersion
to reclaim the storage for the file. Document revisions remain on the server until you delete them."This seems to have resolved that problem.
Note I wouldn't be concerned that
currentVersionOfItemAtURL
differed between devices. I understand it is essentially arbitrary and will depend on the order changes occurred on the device.Also note that all the conflict resolution actions should be wrapped inside a file coordinator: