• 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: Newbie with stupid question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.
  • Follow-Ups:
    • Re: Newbie with stupid question
      • From: email@hidden
References: 
 >Re: Newbie with stupid question (From: email@hidden)

  • Prev by Date: Re: How do you set the NSTableView Indicator Image
  • Next by Date: Re: AppleScripts from Cocoa apps
  • Previous by thread: Re: Newbie with stupid question
  • Next by thread: Re: Newbie with stupid question
  • Index(es):
    • Date
    • Thread