Re: takeValue:forKey and BOOL
Re: takeValue:forKey and BOOL
- Subject: Re: takeValue:forKey and BOOL
- From: Jérôme Laurens <email@hidden>
- Date: Thu, 3 Apr 2003 19:08:21 +0200
Le jeudi, 3 avr 2003, ` 18:16 Europe/Zurich, Jane a icrit :
>
We have found what appears to be an error in takeValue:forKey when the
>
instance variable in the target object is a BOOL. The following code
>
illustrates problem:
I am afraid this bug is yours: the cocoa doc says
- (void)takeValue:(id)value forKey:(NSString *)key
- (id)valueForKey:(NSString *)key
so you cannot use a BOOL, you must wrap the flag in a NSNumber, use
instead
TestObject.h
@interface TestObject : NSObject {
BOOL aBool;
}
-(void)setABool:(NSNumber *)yesNo;
-(NSNumber *)aBool;
@end
AnObject.m
#import "TestObject.h"
@implementation TestObject
-(void)setABool:(NSNumber *)yesNo { aBool = [yesNo boolValue]; }
-(NSNumber *)aBool { return [NSNumber numberWithBool: aBool]; }
@end
_______________________________________________
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.