On 01/02/2013, at 4:08 PM, Kyle Sluder <k...@ksluder.com> wrote:

> But CFTypes *are* NSObjects. So I'm not sure why your case isn't working. Can 
> you be more specific?


This is why the result surprised me - I have "known" this for years, and 
assumed that there wouldn't be a problem with this. But, this is the first time 
I've ever actually tried it, and what I found is that if I have a property, e,g

@property (nonatomic, assign) CGColorRef                myColor;

and I ask for this using

[someObject valueForKey:@"myColor"];

then instead of returning the object, it hits -valueForUndefinedKey: instead.

While that gives me an opportunity to do something to wrap or convert the 
object, I must admit it wasn't the expected behaviour. I have been through all 
the KVC documentation and I could find nothing that stated explicitly whether 
CFTypes can be accessed via KVC; the lack of mention could imply that they 
can't be, or alternatively, that they can be... ;-)

Incidentally, while I declare these properties as 'assign', they do in fact 
retain, it's just that the property synthesizing mechanism doesn't allow me to 
specify retain for these types. Instead I have to implement the setter manually 
and perform the necessary retains/releases as needed. Perhaps this is a clue? 
Again, I would have thought that the system would 'know' that a CFType is an 
NSObject, and permit the use of retain in the property declaration.

--Graham


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to