On Jan 31, 2013, at 21:08 , Kyle Sluder <k...@ksluder.com> wrote:

> But CFTypes *are* NSObjects.

Only if they're toll-free bridged, and even then they'll need to conform to 
NSCoding if they're going to encode/decode automatically. The 
non-toll-free-bridged ones are memory-managed objects, but not necessarily ObjC 
objects. GCD objects would be a prime example of this.

On Jan 31, 2013, at 21:09 , Graham Cox <graham....@bigpond.com> wrote:

> I also have to override -valueForUndefinedKey: and do this in every object 
> that has properties that are CFTypes.
> 
> My question really is if this is necessary or is there a more cunning, 
> generic way to handle this?


I don't think there's any cunning way. If you're going to override a KVC method 
in every object class that has CFType properties, you may as well use the 
normal pattern of overriding initWithCoder/encodeWithCoder, and encode/decode 
the properties yourself.

You can factor out the details by declaring categories on 
NSKeyedArchiver/NSKeyedUnarchiver that define methods of the form 
encodeCFType:forKey: and decodeCFTypeForKey:.

A more automated approach would be to iterate through your list of properties, 
use the ObjC runtime functions to get the property attributes, one of which is 
the return type, look for specific types, and bypass KVC for the CFType types.

_______________________________________________

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