• 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: if ([[NSUserDefaults preferences] check box]==true) ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: if ([[NSUserDefaults preferences] check box]==true) ?


  • Subject: Re: if ([[NSUserDefaults preferences] check box]==true) ?
  • From: Alastair Houghton <email@hidden>
  • Date: Sun, 9 Nov 2003 10:54:40 +0000

Also, if you are testing against true, *don't* use == to do it. C and
most of the code written in it assumes that any non-zero value is true,
so you can trip yourself up and end-up in a situation where something
appears (to your code) to be neither true or false.

IMO it's also not a good idea to use == for comparison with false
either, mainly because that makes the test different to the one you use
for true... but that's a style issue and we shouldn't really be
discussing those because of the fire risk ;->

Kind regards,

Alastair.

On 9 Nov 2003, at 05:36, Kevin Wojniak wrote:

> Try using...
>
> if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"checkBox"]
> boolValue])
>
> ...Kevin
>
>
> On Nov 8, 2003, at 6:27 PM, Kurt Marek wrote:
>
>> if ([[NSUserDefaults standardUserDefaults]
>> objectForKey:@"checkBox"]==1)
>>
>> if ([[NSUserDefaults standardUserDefaults]
>> objectForKey:@"checkBox"]==true)
>>
>> if ([[NSUserDefaults standardUserDefaults]
>> objectForKey:@"checkBox"]==YES)
>>
>> if ([[[NSUserDefaults standardUserDefaults]
>> objectForKey:@"checkBox"]
>> isEqual:@"true")

[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
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: if ([[NSUserDefaults preferences] check box]==true) ?
      • From: Scott Ellsworth <email@hidden>
    • Re: if ([[NSUserDefaults preferences] check box]==true) ?
      • From: Wade Tregaskis <email@hidden>
References: 
 >if ([[NSUserDefaults preferences] check box]==true) ? (From: Kurt Marek <email@hidden>)
 >Re: if ([[NSUserDefaults preferences] check box]==true) ? (From: Kevin Wojniak <email@hidden>)

  • Prev by Date: Re: NSUserDefaultsController
  • Next by Date: Key-Value Observing in Java
  • Previous by thread: Re: if ([[NSUserDefaults preferences] check box]==true) ?
  • Next by thread: Re: if ([[NSUserDefaults preferences] check box]==true) ?
  • Index(es):
    • Date
    • Thread