• 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: Wade Tregaskis <email@hidden>
  • Date: Sun, 9 Nov 2003 13:45:46 +1100

I've tried all of the following and none of them seem to work:

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")

Remember that dictionaries associated objects (keys) with objects (values). 1, true and YES or not objects. You were closer with @"true", since that is an object, but as has been pointed out the standard mechanism for storing numbers (and thus booleans) is the NSNumber class.

Wade Tregaskis
-- Sed quis custodiet ipsos custodes?
_______________________________________________
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.

References: 
 >if ([[NSUserDefaults preferences] check box]==true) ? (From: Kurt Marek <email@hidden>)

  • Prev by Date: Re: if ([[NSUserDefaults preferences] check box]==true) ?
  • Next by Date: Re: can't rename file
  • Previous by thread: Re: if ([[NSUserDefaults preferences] check box]==true) ?
  • Next by thread: Re: if ([[NSUserDefaults preferences] check box]==true) ?
  • Index(es):
    • Date
    • Thread