On 10 Nov 2013, at 1:21 pm, Uli Kusterer <witness.of.teacht...@gmx.net> wrote:
> Are you saying there’s no way to get the async document loading mechanism to > open the empty document first, then asynchronously load the data into that > window (giving you the opportunity to show partially loaded content or a > progress indicator *inside* the document window)? Yep, that’s what I’m saying: NSDocument reads the file first and then makes the UI. If the file read takes a long time, then the UI does not appear until it’s done - if the file read is done asynchronously there is no feedback at all that anything happened when you clicked ‘Open’, except that the NSOpenPanel goes away. On 9 Nov 2013, at 7:39 pm, Kyle Sluder <k...@ksluder.com> wrote: > 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. In my case I’m setting up the progress as part of the call to -[NSDocument readFromFileWrapper:…]. This might be the wrong place to do it, because it is invoked at other times, such as when reverting (OK) and from Versions (not OK). In the latter case, I have a flag I can check to see if I’m currently in Versions and skip the progress stuff then. It’s not super-clean, but it avoids messing with NSDocumentController, though I’ll have to give that some thought - might be the better idea. My Progress code is designed to work from a thread or not - the modal session is always done on the main thread - for the sake of discussion I simplified the description of what I’m doing. —Graham _______________________________________________ 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