• 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: Converting between property names?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Converting between property names?


  • Subject: Re: Converting between property names?
  • From: Greg Parker <email@hidden>
  • Date: Tue, 10 Apr 2012 14:40:29 -0700

On Apr 10, 2012, at 1:49 PM, Rick Mann <email@hidden> wrote:
> Are there functions provided in the Objective-C runtime to convert property names? For example, say I have a key name like "fooKey", and I want to get "FooKey", or the setter name "setFooKey" from it. I could do the name munging myself, but I wonder if there aren't edge cases. For example, "setURL" should covert to "URL", not "uRL".
>
> In my particular case, I'm trying to implement functionality like +keyPathsForValuesAffecting<Key>. It takes a key name (usually something that starts with a lower-case letter) and changes it to start with an upper-case letter, then appends it to "keyPathsForValuesAffecting" to create the selector name.
>
> Are those conversion methods provided anywhere? I looked through the Obj-C runtime and didn't see anything, but I didn't read every single page.

The code to derive the default setter and getter method names from a property name is in the compiler somewhere.

The runtime can tell you the setter and getter and ivar names for a particular class's property, but knows nothing about key paths or name to name conversion.


--
Greg Parker     email@hidden     Runtime Wrangler



_______________________________________________

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: Converting between property names?
      • From: Jean-Daniel Dupas <email@hidden>
References: 
 >Converting between property names? (From: Rick Mann <email@hidden>)

  • Prev by Date: Re: How to set the foreground and background colors of selected text in a field editor (NSTextView)?
  • Next by Date: Re: Converting between property names?
  • Previous by thread: Converting between property names?
  • Next by thread: Re: Converting between property names?
  • Index(es):
    • Date
    • Thread