Hi Kyle,

Many thanks for your reply, much appreciated. I guess it's finally time to get 
my hands dirty and learn how to use threads properly, then. :) (Although I was 
under the impression that working with NSAttributedStrings wasn't thread-safe 
according to other mail list postings. I could be wrong, though, given that I 
have managed to get away with barely touching threads thus far, and I'm not 
sure if that would include just loading an attributed string from a file.) I do 
need to stay 10.4-compatible which limits my use of the newer threading 
methods, although I suppose I could optimise for 10.6 so that users get the 
benefits of having the latest OS.

As for my use of a modal dialogue, sorry, I should have been more clear. The 
only places I use anything like that are for loading panels (import/export); it 
was merely my first resort given that I wasn't sure of the correct approach.

So, if I understand correctly, a threaded approach would go something like this:

• The user selects some documents.
• A "loading" progress indicator appears in the view where the text will be 
shown once ready.
• A separate thread is spawned to load all of those documents into various 
attributed strings and then into one long text storage.
• If the user selects something else, the other thread is cancelled.
• When the loading thread is completed, it returns each of the individual 
attributed strings that were loaded from file and the main text storage (or 
perhaps each attributed string one at a time) to the main thread so that I can 
load them.

If anyone knows of any good tutorials on threading for this sort of thing, I'd 
be very grateful for links, otherwise I'll be off to the Apple docs and 
CocoaDevCentral etc forthwith (I know there's a good chapter on threads in my 
Anguish/Buck/Yackman book, but that's now out of date for the newer methods).

Thanks again and all the best,
Keith


----- Original Message ----
From: Kyle Sluder <[email protected]>
To: Keith Blount <[email protected]>
Cc: "[email protected]" <[email protected]>
Sent: Tue, May 18, 2010 5:36:58 PM
Subject: Re: Cancelling a loading loop in order to load something else

On May 18, 2010, at 8:07 AM, Keith Blount <[email protected]> wrote:

> Should I forge ahead with trying to get a modal session working for this, or 
> is there a better solution I'm missing?

Perform the loading asynchronously or on a background thread. With 10.6, you 
could enqueue a block on a background queue for each file that needs to be 
loaded. Then you never have to block the main thread. It also questions your 
use of a modal dialog, but perhaps there are good UX reasons for that.

--Kyle Sluder




_______________________________________________

Cocoa-dev mailing list ([email protected])

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

This email sent to [email protected]

Reply via email to