Re: takeValue:forKey and BOOL
Re: takeValue:forKey and BOOL
- Subject: Re: takeValue:forKey and BOOL
- From: Vince DeMarco <email@hidden>
- Date: Thu, 3 Apr 2003 09:46:18 -0800
On Thursday, April 3, 2003, at 8:16 AM, Jane wrote:
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:
AppController.h
@interface AppController : NSObject {
IBOutlet NSTableView *tableView;
NSMutableArray *aMutableArray;
}
@end
AppController.m
#import "AppController.h"
#import "TestObject.h"
@implementation AppController
-(void)awakeFromNib {
aMutableArray = [[NSMutableArray
arrayWithObject:[[TestObject alloc] init]] retain];
[tableView setDataSource:self];
[[[tableView tableColumns] objectAtIndex:0] setIdentifier:@"aBool"]; }
-(int)numberOfRowsInTableView:(NSTableView *)aTableView {
return [aMutableArray count]; }
-(id)tableView:(NSTableView *)aTableView
objectValueForTableColumn:(NSTableColumn *)aTableColumn
row:(int)rowIndex {
return [[aMutableArray objectAtIndex:rowIndex]
valueForKey:[aTableColumn identifier]]; }
-(void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject
forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex {
[[aMutableArray objectAtIndex:rowIndex] takeValue:anObject
forKey:[aTableColumn identifier]]; }
@end
TestObject.h
@interface TestObject : NSObject {
BOOL aBool;
}
-(void)setABool:(BOOL)yesNo;
-(BOOL)aBool;
@end
AnObject.m
#import "TestObject.h"
@implementation TestObject
-(id)init {
if (self = [super init]) aBool = YES;
return self;
}
-(void)setABool:(BOOL)yesNo { aBool = yesNo; }
-(BOOL)aBool { return aBool; }
@end
IB was used to add one NSTableView with one column to the main window.
The initial value of aBool displays in the table correctly as "1". But
when the cell is selected, a value of 0 is typed, and ENTER pressed,
the following error displays on the console:
2003-04-02 09:03:59.908 TakeValueError[576] *** -[NSCFString
charValue]: selector not recognized
2003-04-02 09:03:59.915 TakeValueError[576] Exception raised during
posting of notification. Ignored. exception: *** -[NSCFString
charValue]: selector not recognized
Is this a known problem or should I use Apple's error submission
process to notify Apple?
We did discover the following workaround:
- (void)setABool:(int)yesNo { aBool = yesNo; }
I think its a bug, please file one.
vince
_______________________________________________
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.