• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: KVC and Core Foundation types
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: KVC and Core Foundation types


  • Subject: Re: KVC and Core Foundation types
  • From: Quincey Morris <email@hidden>
  • Date: Thu, 31 Jan 2013 21:46:43 -0800

On Jan 31, 2013, at 21:08 , Kyle Sluder <email@hidden> 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 <email@hidden> 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 (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

  • Follow-Ups:
    • Re: KVC and Core Foundation types
      • From: Charles Srstka <email@hidden>
    • Re: KVC and Core Foundation types
      • From: Kyle Sluder <email@hidden>
References: 
 >KVC and Core Foundation types (From: Graham Cox <email@hidden>)
 >Re: KVC and Core Foundation types (From: Seth Willits <email@hidden>)
 >Re: KVC and Core Foundation types (From: Kyle Sluder <email@hidden>)

  • Prev by Date: Re: KVC and Core Foundation types
  • Next by Date: Re: KVC and Core Foundation types
  • Previous by thread: Re: KVC and Core Foundation types
  • Next by thread: Re: KVC and Core Foundation types
  • Index(es):
    • Date
    • Thread