Re: How to cancel a loading document in NSDocument's readFromURL:ofType:error method ?
Re: How to cancel a loading document in NSDocument's readFromURL:ofType:error method ?
- Subject: Re: How to cancel a loading document in NSDocument's readFromURL:ofType:error method ?
- From: Mike Abdullah <email@hidden>
- Date: Fri, 10 Feb 2012 22:25:26 +0000
On 10 Feb 2012, at 21:25, Gilles Celli wrote:
> Opening the ASCII file can take up to 15-20 sec ( > 150MB), so I made some changes as you suggested by moving the progressWindowController alloc/init before the allocation of asciiFileContents...
> And you're right I should have put addWindowController: in makeWindowController....
>
> This makes the opening of the file a little more responsive (clicking the button) but not really what I expect...
>
>> Never blindly assign to error pointers. Check the caller is actually interested in receiving an error first.
> Which caller do you mean ?
Cocoa is calling your method. You should do:
if (outError) *outError = …
Otherwise it'll crash should outError be nil. The static analyser can warn you of this.
>
> Maybe the way to go is to use a new detached thread only for the progress window, or to use Kyle's approach by using NSOperationQueue..
Again I repeat: AppKit is NOT thread safe. You must perform all UI on the main thread. You already have a detached thread. There is likely no point trying to start up another one.
_______________________________________________
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