You want to be able to solve conflicts between two or
more versions of a document (managed through
UIDocument) in iCloud.
otherVersionsOfItemAtURL: class method of
to detect different versions of the current revision of the document
you are managing using an instance of
UIDocument. Each version of a document is of
NSFileVersion. The procedure
to take is as follows:
Instantiate and open a document.
notifications (see Recipe 17.6).
Check if the
documentState property of the document
that caused the aforementioned notification to be fired has the
state. If yes, then we will proceed to the next step. If not, we
will handle the issue in a different way.
When a conflict occurs on a document, iCloud will automatically attempt to resolve that conflict by either merging two or more revisions of that document together, or simply taking the latest version. Whatever iCloud does, it will give you a revision of the document to work with. This revision is called the current version of that document.
We will use the
currentVersionOfItemAtURL: class method
NSFileVersion class to
get the current version of the document by passing the URL of the
document to this method.
Next, we will use the
otherVersionsOfItemAtURL: class method
Version class to get all other versions of the document, by passing the URL of the document ...