• 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: Extending KVO to scalar struct types?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Extending KVO to scalar struct types?


  • Subject: Re: Extending KVO to scalar struct types?
  • From: Quincey Morris <email@hidden>
  • Date: Fri, 29 Aug 2014 05:20:38 +0000

On Aug 28, 2014, at 21:09 , Graham Cox <email@hidden> wrote:

> Actually that will work for me. I only need to support size, points and rects at the moment, so it's easy enough to use the -objCType to see which one I have and then just change the field according to which specific string I pass. A category on NSValue will wrap that up neatly enough.

You can get the information you need out of the Obj-C runtime. In the case where a key represents an @property (which is the only case I actually use) the code looks like this (omitting error checking):

	objc_property_t classProperty = class_getProperty (owningClass, classPropertyName);
	NSString* attributes = @(property_getAttributes (classProperty));
	NSArray* components = [attributes componentsSeparatedByString: @",”];

Now you have an array of strings representing property attributes, the first character of which is the attribute type. The property type is attribute type “T”, and the rest of the string for a struct type has this form:

	{<struct-tag-name>=â€Ĥ

which you can use to figure out what you need.




_______________________________________________

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: Extending KVO to scalar struct types?
      • From: Graham Cox <email@hidden>
References: 
 >Extending KVO to scalar struct types? (From: Graham Cox <email@hidden>)
 >Re: Extending KVO to scalar struct types? (From: Ken Thomases <email@hidden>)
 >Re: Extending KVO to scalar struct types? (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: Extending KVO to scalar struct types?
  • Next by Date: Re: Extending KVO to scalar struct types?
  • Previous by thread: Re: Extending KVO to scalar struct types?
  • Next by thread: Re: Extending KVO to scalar struct types?
  • Index(es):
    • Date
    • Thread