Re: Cocoa says not KVC compliant
Re: Cocoa says not KVC compliant
- Subject: Re: Cocoa says not KVC compliant
- From: Nathan Vander Wilt <email@hidden>
- Date: Wed, 2 Jul 2008 13:33:21 -0700
On Jul 2, 2008, at 10:13 AM, Milen Dzhumerov wrote:
I've run into a something I find strange. I've got a property
declared as:
@property(readwrite, assign, nonatomic) CGImageRef image;
...
When I try to set it using KVC (e.g. [obj setValue:[NSValue
valueWithPointer:image] forKeyPath:@"image"]), it says [<*ClassName*
0x133050> setValue:forUndefinedKey:]: this class is not key value
coding-compliant for the key image.'
Keep in mind that the core KVC messages are -setValue:(id)forKey: and -
(id)valueForKey:. That is, the KVC functions deal with values that are
true Objective-C objects.
Your [NSValue valueWithPointer:] shows you are somewhat aware of
this, but if you look at http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/Concepts/DataTypes.html
you will see that neither a CGImageRef nor a plain old pointer
(void*) are supported scalar types in KVC.
I may be wrong, but my understanding is that you will not be able to
use KVC on this property, at least not without declaring the property
type to be an NSValue*, which may or may not be an appropriate
solution to your particular problem.
hope this helps,
-natevw
_______________________________________________
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