Re: KVC and Core Foundation types
Re: KVC and Core Foundation types
- Subject: Re: KVC and Core Foundation types
- From: Charles Srstka <email@hidden>
- Date: Thu, 31 Jan 2013 23:58:44 -0600
On Jan 31, 2013, at 11:46 PM, Quincey Morris <email@hidden> wrote:
> On Jan 31, 2013, at 21:08 , Kyle Sluder <email@hidden> wrote:
>
>> But CFTypes *are* NSObjects.
>
> Only if they're toll-free bridged
Huh? It's been my understanding that all CFTypes bridge to NSObjects. CGPathRef certainly does:
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
CGPathRef path = CGPathCreateWithRect(CGRectMake(0, 1, 2, 3), NULL);
for (Class class = [(__bridge id)path class]; class != nil; class = [class superclass]) {
NSLog(@"%@", NSStringFromClass(class));
}
CGPathRelease(path);
}
return 0;
}
2013-01-31 23:55:51.570 typetest[2906:303] __NSCFType
2013-01-31 23:55:51.576 typetest[2906:303] NSObject
Given this, I'd expect you could make it work with KVC by making the property an id instead of a CGPathRef, and doing a bridge cast every time you want to use it. Of course, overriding valueForKey: is probably cleaner though.
Charles
_______________________________________________
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