• 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
valueForKey: Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

valueForKey: Question


  • Subject: valueForKey: Question
  • From: Jeff LaMarche <email@hidden>
  • Date: Sun, 15 Jan 2006 11:56:26 -0500

This may be one of those situations where information about "why" something is done is not available, but I wanted to ask because I know that I am going to be asked.

Okay, so, the preferred naming convention for accessor methods in Objective-C is to use the name of the instance variable (e.g. foo) rather than using get (e.g. getFoo). This convention seems to be almost universally accepted by Cocoa programmers, is stated in several places, is generally followed in the Cocoa Frameworks, and is also used by Xcode when using the class designer.

With that being the case, why does the default implementation of valueForKey: look first for getFoo and only look for foo after trying unsuccessfully with the non-preferred name? It seems inefficient to place the preferred accessor name second in the search pattern. I know that the performance impact is minimal, but it still seems odd to me.

I'm writing an article right now where I've got the Objective-C naming convention and the valueForKey: search order stated on the same page, and it just looks wrong. I'm sure I'm going to get questions about it, so wanted to preemptively put in the reason for the discrepancy if I could discover it.

Thanks much,
Jeff




_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Prev by Date: Re: Having trouble with NSTimer and runModalForWindow [Solved]
  • Next by Date: key-value observing: 10.3.9 vs. 10.4.x
  • Previous by thread: Address Book style card view
  • Next by thread: key-value observing: 10.3.9 vs. 10.4.x
  • Index(es):
    • Date
    • Thread