• 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
KVC To-Many and BOOL
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: KVC To-Many and BOOL
      • From: Charles Steinman <email@hidden>
  • Prev by Date: Re: Getting PDF data from a webView
  • Next by Date: kAXPositionAttribute and kAXSizeAttribute
  • Previous by thread: Re: Coordinates of Pixels
  • Next by thread: Re: KVC To-Many and BOOL
  • Index(es):
    • Date
    • Thread