Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically resolve NSDocument iCloud version conflicts?

I have a Mac "Shoebox" app that internally uses NSDocument objects, but does not expose the concept of individual documents to the user. (I rely on NSDocument to make syncing via iCloud easier.)

My problem is that when a version conflict arises, my app shows the default NSDocument conflict resolution alert (see below) letting the user pick one or two winners.

In the concept of my app this doesn't make sense. Is there a way to intercept/prevent that alert and handle the conflict programmatically?

I know that I can detect version conflicts with the code below. However, I still need to prevent the alert sheet.

[NSFileVersion unresolvedConflictVersionsOfItemAtURL:document.fileURL];

Example conflict resolution alert:

Example conflict resolution alert

like image 276
Mark Avatar asked Oct 25 '25 23:10

Mark


2 Answers

You can override + (BOOL)usesUbiquitousStorage and return NO. This will no longer show the ubiquity conflict panel.

like image 124
berbie Avatar answered Oct 28 '25 23:10

berbie


This is the built in behavior of NSDocument when it discovers there are unresolved version conflicts. If you do not wish to use it you'll have to drop support for NSDocument and use a lower level abstraction like NSFileManager + NSFileVersion.

like image 39
ImHuntingWabbits Avatar answered Oct 29 '25 01:10

ImHuntingWabbits