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
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 mails | Author | Date |
|---|---|---|
| Milen Dzhumerov | Jul 2, 19:13 | |
| Alex Wait | Jul 2, 21:26 | |
| Nathan Vander Wilt | Jul 2, 22:33 | |
| Chris Suter | Jul 2, 22:34 | |
| mmalc crawford | Jul 2, 23:04 |






Cocoa mail archive

