Re: how do I put boolean variables in a NSDictionary?
Re: how do I put boolean variables in a NSDictionary?
- Subject: Re: how do I put boolean variables in a NSDictionary?
- From: August Trometer <email@hidden>
- Date: Mon, 19 Jun 2006 16:09:09 -0400
[NSNumber numberWithBool:YES]...
Then
[[dict objectForKey:@"compilation"] boolValue]
-- August
On Jun 19, 2006, at 3:57 PM, Alan Smith wrote:
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
_______________________________________________
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