On Nov 9, 2013, at 12:39 PM, Kyle Sluder <k...@ksluder.com> wrote:

> I would seriously consider implementing this approach. My general idea is to 
> subclass NSDocumentController and put up a progress panel before loading the 
> document.
> 
> Unfortunately it doesn't look like NSDocumentController makes this easy. 
> You'd have to put up the UI in 
> -openDocumentWithContentsOfURL:display:completionHandler:, but you won't know 
> if NSDocumentController has determined it actually needs to create a document 
> until the completion handler executes. One workaround would be to 
> delay-perform setting up the progress panel and tear it down in the 
> completion handler, but that would only work for types that are opened 
> asynchronously (the panel would never appear for synchronous loading). A more 
> elaborate solution involving overriding -makeDocumentWithContentsOfURL: may 
> also be required.
> 
> This happens to be a problem I need to solve sometime soon, so thanks for 
> getting me to chew on it.

What I usually do is just have NSDocument's readFromData/URL/fileWrapper/etc 
method not actually do much, and then in windowControllerDidLoadNib: put up a 
progress bar, and start the loading in a background thread. You can either do 
this by hiding the main window and displaying the progress bar in a separate 
window, or by showing the empty document window and putting up a sheet with the 
progress bar in it while the document window is populated with data.

You could use a global operation queue with a max concurrent operation count 
set in order to limit the number of threads that will be created in the 
Versions browser.

Charles

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to