Re: Newbie with stupid question
Re: Newbie with stupid question
- Subject: Re: Newbie with stupid question
- From: Ondra Cada <email@hidden>
- Date: Mon, 18 Mar 2002 14:42:51 +0100
On Monday, March 18, 2002, at 08:37 , email@hidden wrote:
[gamma setEnabled:([sender state] == NSOnState) ? YES : NO];
You might perhaps regard that more readable, but IMHO
[gamma setEnabled:[sender state] == NSOnState];
is *ways* cleaner -- the pattern of "(boolean expression)?YES:NO" looks to
me as very particularly, ahem, impractical.
Besides, thanks to this documentation excerpt
===
Although using the enumerated constants is preferred, value can also be an
integer. If the cell has two states, zero is treated as NSOffState, and a
non-zero value is treated as NSOnState. If the cell has three states, zero
is treated as NSOffState; a negative value, as NSMixedState; and a
positive value, as NSOnState.
===
you can use even the simplest and IMHO best readable
[gamma setEnabled:[sender state]];
(with some caveat in case sender allows mixed state, but actually I guess
in majority of cases this code would do what you actually wanted, whilst
yours would not ;))
---
Ondra Cada
OCSoftware: email@hidden
http://www.ocs.cz
2K Development: email@hidden
http://www.2kdevelopment.cz
private email@hidden
http://www.ocs.cz/oc
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.