Re: Writing out a BOOL value to a .plist
Re: Writing out a BOOL value to a .plist
- Subject: Re: Writing out a BOOL value to a .plist
- From: Dirk Stegemann <email@hidden>
- Date: Sat, 27 May 2006 04:04:10 +0200
Hi,
Am 26.05.2006 um 22:40 schrieb Scott Mitchell:
Thanks that works. I don't know why I did not see that method. I
know I have used this before.
(...)
[ dictInfo setObject: [ NSNumber numberWithBool: YES ] forKey:
BBDM_gadget ]
Just to provide an alternativ way which is also working fine, but --
thanks to toll-free bridging of CoreFoundation's CFBooleanRef type
(which is a valid plist type) -- doesn't require to send a method to
the NSNumber class:
- (void)setBoolValue:(BOOL)theBOOL forKey:(NSString*)theKey intoDict:
(NSMutableArray*)theDict;
{
[theDict setObject:(id)(theBOOL ? kCFBooleanTrue :
kCFBooleanFalse) forKey:theKey];
}
Not sure how expensive 'CFBooleanGetValue()' is, though:
- (void)boolValueForKey:(NSString*)theKey fromDict:(NSMutableArray*)
theDict;
{
return CFBooleanGetValue([theDict objectForKey:theKey]);
}
Regards,
Dirk Stegemann
_______________________________________________
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