• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Cancelling a loading loop in order to load something else
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cancelling a loading loop in order to load something else


  • Subject: Re: Cancelling a loading loop in order to load something else
  • From: Keith Blount <email@hidden>
  • Date: Tue, 18 May 2010 10:33:53 -0700 (PDT)

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@hidden>
To: Keith Blount <email@hidden>
Cc: "email@hidden" <email@hidden>
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@hidden> 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@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

References: 
 >Cancelling a loading loop in order to load something else (From: Keith Blount <email@hidden>)
 >Re: Cancelling a loading loop in order to load something else (From: Kyle Sluder <email@hidden>)

  • Prev by Date: Re: Notifications on main thread
  • Next by Date: Detecting modifier key down when opening a menu?
  • Previous by thread: Re: Cancelling a loading loop in order to load something else
  • Next by thread: Notifications on main thread
  • Index(es):
    • Date
    • Thread