simple AppKit / multithreading question
simple AppKit / multithreading question
- Subject: simple AppKit / multithreading question
- From: Aurélien Hugelé <email@hidden>
- Date: Fri, 11 Mar 2005 14:44:45 +0100
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 !
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 !
_______________________________________________
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