• 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: Making a Window Class Invocable from Any Thread
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Making a Window Class Invocable from Any Thread


  • Subject: Re: Making a Window Class Invocable from Any Thread
  • From: Chris Hanson <email@hidden>
  • Date: Tue, 04 Nov 2008 22:29:20 -0800

On Nov 4, 2008, at 2:22 PM, Jerry Krinock wrote:

I have a class which programatically creates and manipulates an alert window, like NSAlert except it's capable of much more. It exposes about 55 methods, doing stuff like like -setTitle:, - setButtonTitle:, -setProgressAmount:, -removeAllSubviews, - setPopupTitles:, setIconStyle: etc., etc.

Now that I'm learning the coolness of NSOperation, I'd like to be able to invoke these methods from any thread (any NSOperation).

I'd actually caution you against this. Keep your processing distinct from your user interface, don't mix the two. Use some form of intermediate "status" object to pass information back to your main thread for presentation to the user, rather than trying to interact with the user from multiple threads at once.


Otherwise you'll wind up doing one of two things:

(1) Serializing everything as a side effect of attempting to keep interaction with the user safe; or,

(2) Dealing regularly with hard-to-address bugs that are ultimately due to multiple threads interacting with the same data without correct locking.

By keeping the logic that operates on your data distinct from your user interface, you can much more easily scale your logic along with the user's hardware, and keep debugging of both your UI and logic straightforward.

  -- Chris

_______________________________________________

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


  • Follow-Ups:
    • Re: Making a Window Class Invocable from Any Thread
      • From: Jerry Krinock <email@hidden>
References: 
 >Making a Window Class Invocable from Any Thread (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Re: NSTableView
  • Next by Date: Custom view controller
  • Previous by thread: Re: Making a Window Class Invocable from Any Thread
  • Next by thread: Re: Making a Window Class Invocable from Any Thread
  • Index(es):
    • Date
    • Thread