Asynchronous document migration use cases
Asynchronous document migration use cases
- Subject: Asynchronous document migration use cases
- From: Dave Fernandes <email@hidden>
- Date: Fri, 23 Sep 2011 13:30:19 -0400
I have a document-based app (Core Data, but that isn't important here) that can have fairly large documents. Migrating these documents from an old format to the new one can take several seconds (to decode, transform and re-encode data), so I need to do it off the main thread. It seems to work if I create an NSOperation to do the migration in the openDocumentWithContentsOfURL:display:error: method of my NSDocumentController subclass.
So if a document needs migration, this method returns nil with an NSCocoaErrorDomain NSUserCancelledError, queues the NSOperation, and then after the asynchronous migration completes, [super openDocumentWithContentsOfURL:display:error:] is called (on the main thread) to open the document.
While the migration is in progress, a modeless dialog is shown with a progress indicator and cancel button, and further calls to open the same document are ignored (returns NSCocoaErrorDomain NSUserCancelledError).
My question is: Will this strategy miss (or miss-handle) any use cases on Snow Leopard or Lion? Can openDocumentWithContentsOfURL:display:error: ever be called off the main thread in response to user actions (assuming my code doesn't do this)?
NOTE: My override of reopenDocumentForURL:withContentsOfURL:display:completionHandler: does not migrate documents since it would be confusing to launch the app and have a migration start immediately. So if it is called with a document that needs migration, it does nothing.
Thanks for any feedback.
Dave_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden