• 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: takeValue:forKey and BOOL
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >takeValue:forKey and BOOL (From: Jane <email@hidden>)

  • Prev by Date: Re: stringByTrimmingCharactersInSet: Bug
  • Next by Date: RE: nscolorwell cell question
  • Previous by thread: takeValue:forKey and BOOL
  • Next by thread: Re: takeValue:forKey and BOOL
  • Index(es):
    • Date
    • Thread