• 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
how do I put boolean variables in a NSDictionary?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

how do I put boolean variables in a NSDictionary?


  • Subject: how do I put boolean variables in a NSDictionary?
  • From: "Alan Smith" <email@hidden>
  • Date: Mon, 19 Jun 2006 15:57:37 -0400

Hi all,
I want to put a bool in a NSDictionary to save in the NSUserDefaults.
I've tried using this:

NSDictionary *dict = [NSDictionary
dictionaryWithObjectsAndKeys:@"Cheat", @"type", YES, @"compilation",
nil];

I get a SIGBUS error. It's because of the bool I know. I tried:

NSDictionary *dict = [NSDictionary
dictionaryWithObjectsAndKeys:@"Cheat", @"type", [NSNumber
numberWithInt: 0], @"compilation", nil];

And then:

if ([[dict valueForKey: @"compilation"] boolValue])

and that goes through. But that isn't as pretty or understandable as
it could be. The NSUserDefaults can use setBool:forKey: but I want to
put a dictionary with a bool in the defaults not a bool directly in
the defaults. NSUserDefaults loads plist files which has a Root
dictionary, so it isn't impossible to put booleans in a dictionary.

I'll repeat the question: How do I put a boolean in a NSDictionary?

Thanks, Alan
--
// Quotes from yours truly -------------------------
"You don't forget, you just don't remember."
"Maturity resides in the mind."
"Silence is the Universe's greatest gift."
"Don't waste your life doing things others have already done."
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: how do I put boolean variables in a NSDictionary?
      • From: August Trometer <email@hidden>
    • Re: how do I put boolean variables in a NSDictionary?
      • From: James Bucanek <email@hidden>
  • Prev by Date: Getting average power / peak power (sound monitoring)
  • Next by Date: Re: how do I put boolean variables in a NSDictionary?
  • Previous by thread: Re: Getting average power / peak power (sound monitoring)
  • Next by thread: Re: how do I put boolean variables in a NSDictionary?
  • Index(es):
    • Date
    • Thread