• 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: BOOL value in Dictionary
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: BOOL value in Dictionary


  • Subject: Re: BOOL value in Dictionary
  • From: Heinrich Giesen <email@hidden>
  • Date: Fri, 21 Nov 2008 16:42:33 +0100


Hi,
besides what Ken Thomases and Graham Cox already said, I have a remark concerning programming style:
            if ( colorSwitch == YES) {
                [colorBox setState:NSOnState];
            }
            else {
                [colorBox setState:NSOffState];
            }


It is bad to test a Boolean value with "colorSwitch==NO" and it is a very very bad habit to test
a Boolean value with "== YES" (there is a longer thread in this forum). It is not that difficult to
smoothly deal with Boolean expressions. It's not a question of efficiency but a question of style,
so the above snippet is equivalent (and more Boolean-like):


[colorBox setState: colorSwitch ? NSOnState : NSOffState];

Heinrich

--
Heinrich Giesen
email@hidden

_______________________________________________

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: BOOL value in Dictionary
      • From: David Blanton <email@hidden>
  • Prev by Date: WebServices / SOAP / REST
  • Next by Date: NSIndexSet
  • Previous by thread: Re: BOOL value in Dictionary
  • Next by thread: Re: BOOL value in Dictionary
  • Index(es):
    • Date
    • Thread