Re: What should we do if file-opening takes a long time?
Re: What should we do if file-opening takes a long time?
- Subject: Re: What should we do if file-opening takes a long time?
- From: Graham Cox <email@hidden>
- Date: Sun, 01 Jan 2017 12:35:57 +1100
NSDocument will open it on a background thread if you implement +canConcurrentlyReadDocumentsOfType: to return YES for that file type.
All of the data is read in and the model prepared before any user interface (e.g. the document window) is created. If there’s a failure you’ll see an error alert.
There is no automatic provision for a progress dialog, so you’ll have to implement your own. Because there’s no document window until the read fully succeeds, this will need to be a modeless dialog rather than a sheet, because there’s no parent to attach it to. Since there could be more than one of these file opens going on asynchronously, you might want to consider a stacked progress design, but you have to do all that yourself.
NSProgress is thread safe and might be useful for this.
—Graham
> On 31 Dec 2016, at 7:52 PM, Daryle Walker <email@hidden> wrote:
>
> Let’s assume we’re using a NSDocument-based application. If we’re opening a big file, like a gigabyte or more, does the system code automatically show a progress bar dialog? Or does the user look at a whole bunch of nothing (i.e. wondering if the app locked up)?
>
> If the latter, I guess we would (eventually) implement a opening progress window ourselves. I’m thinking of a app-global window that contains a list. Each list item corresponds to an object of a NSOperation subclass; where the operation and list item have the same lifetime. The operation could have a NSProgress object that the list item tracks. (Hopefully NSProgress is sufficiently thread-safe.) Is that workable? Is there a better idea?
_______________________________________________
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