• 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: simple AppKit / multithreading question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: simple AppKit / multithreading question


  • Subject: Re: simple AppKit / multithreading question
  • From: James Housley <email@hidden>
  • Date: Fri, 11 Mar 2005 09:50:18 -0500

Aurélien Hugelé wrote:
Hi list !

my app is heavily multithreaded, and needs to modify the GUI. I know that the interface mods needs to be done in the main thread.
Its is very convenient to use performSelectorInMainThread: for my secondary threads... but still, i have a question :


most of my threads need to modify the enabled/disabled state or the hidden/shown state of my widgets. I use setEnabled:YES/NO or setHidden:YES/NO

but i can not use performSelectorInMainThread:withObject: here! the argument of this method must be NSObjects ... not BOOL !


[NSNumber nubmerWithBool:<bool value]

That will make a nice object for you.

i ask my self about several possibilities :

1/ adding a category to all my widgets : setEnabled:(NSNumber*)state and setHidden:(NSNumber*)state
=> can be very boring because i potentially need to create a category for all the API method that require a bool or an int or a float ...


2/ adding enable:(id)myWidget / disable:(id)myWidget methods to my code
=> i feel it is poor design... there must be a better cocoa native solution !?


3/ methods like setEnabled: or setHidden: are known to be thread safe, because internally they just set a boolean and call setNeedsDisplay... so there is no need to call the on the main thread...

Sorry for this very newbie question !

Jim

--
/"\   ASCII Ribbon Campaign  .
\ / - NO HTML/RTF in e-mail  .
 X  - NO Word docs in e-mail .
/ \ -----------------------------------------------------------------
email@hidden      http://www.FreeBSD.org     The Power to Serve
email@hidden  http://www.TheHousleys.net
---------------------------------------------------------------------
In God we Trust -- all others must submit an X.509 certificate.
    -- Charles Forsythe <email@hidden>

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: simple AppKit / multithreading question
      • From: "Dennis C. De Mars" <email@hidden>
References: 
 >simple AppKit / multithreading question (From: Aurélien Hugelé <email@hidden>)

  • Prev by Date: Re: NSPopUpButtonCell in custom NSTableColumn in NSTableView - not changing value
  • Next by Date: Rotating an NSView around its center
  • Previous by thread: simple AppKit / multithreading question
  • Next by thread: Re: simple AppKit / multithreading question
  • Index(es):
    • Date
    • Thread