Re: KVC and Core Foundation types
Re: KVC and Core Foundation types
- Subject: Re: KVC and Core Foundation types
- From: Roland King <email@hidden>
- Date: Fri, 01 Feb 2013 14:46:49 +0800
>
> I don't understand that. The search pattern for valueForKey: is documented very clearly and if you have a myColor method or a _myColor instance variable, as you surely must, it should find it and return it. The only question from reading the documentation is .. what should it return it as? Were that the issue, it having a problem converting a CGColorRef to something it can return, I'd not expect valueForUndefinedKey: but some other exception.
> _______________________________________________
>
But right you most definitely are .. it fails in exactly that way.
If I change the property type to a non-object type (I used NSUInteger) and look at the stack trace where KVC is getting the value it's like this
_NSGetUnsignedIntValueWithMethod
_NSGetUsingKeyValueGetter
...
so yes it seems key value coding code looks at the type of the return and calls a method for that particular type. void*s seem to be beyond it and that counts as an undefined key. A note in the documentation about types it can't convert and return might be helpful here. I looked at the return type of the getter method and it's "^v", that's pointer to void is it not? I suppose it would be hard for the runtime to do anything sensible with that generically so it doesn't.
_______________________________________________
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