Skip navigation.
 
mlRe: Cocoa says not KVC compliant
FROM : Nathan Vander Wilt
DATE : Wed Jul 02 22:33:21 2008

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

Related mailsAuthorDate
mlCocoa says not KVC compliant Milen Dzhumerov Jul 2, 19:13
mlRe: Cocoa says not KVC compliant Alex Wait Jul 2, 21:26
mlRe: Cocoa says not KVC compliant Nathan Vander Wilt Jul 2, 22:33
mlRe: Cocoa says not KVC compliant Chris Suter Jul 2, 22:34
mlRe: Cocoa says not KVC compliant mmalc crawford Jul 2, 23:04