KVC To-Many and BOOL
KVC To-Many and BOOL
- Subject: KVC To-Many and BOOL
- From: David Peredo <email@hidden>
- Date: Wed, 18 Jul 2007 19:03:29 -0700
So... I would think that like other KVC methods, when returning
primitive numeric types they are returned as NSNumbers... however
when I'm calling a method such as
- (BOOL)objectInBoolsAtIndex:(unsigned int)index;
by way of...
BOOL test = [[[anObject valueForKey:@"bools"] objectAtIndex:0]
boolValue];
I get a bad access. Any ideas?
Here's the full test code...
//------------------------------------------------------------
#import <Foundation/Foundation.h>
@interface KVCClass : NSObject {
}
- (unsigned int)countOfBools;
- (BOOL)objectInBoolsAtIndex:(unsigned int)index;
@end
@implementation KVCClass
- (unsigned int)countOfBools
{
return 1;
}
- (BOOL)objectInBoolsAtIndex:(unsigned int)index
{
return YES;
}
@end
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
// insert code here...
KVCClass *anObject = [[KVCClass alloc] init];
BOOL test = [[[anObject valueForKey:@"bools"] objectAtIndex:0]
boolValue];
NSLog(@"%i", test);
[anObject release];
[pool release];
return 0;
}
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden