• 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: loop efficiency & messages
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: loop efficiency & messages


  • Subject: Re: loop efficiency & messages
  • From: Philip Mötteli <email@hidden>
  • Date: Wed, 23 Mar 2005 19:00:44 +0100

Am 23.03.2005 um 18:39 schrieb Charilaos Skiadas:
On Mar 23, 2005, at 11:25 AM, Sherm Pendley wrote:
On Mar 23, 2005, at 10:33 AM, Charilaos Skiadas wrote:

I think Johnny was actually referring to the fact that KVC comes for free if you have named your accessors for the item as "setItem:" and "item", and he was referring to using the "item" name for the method, instead of the "getItem" name, which KVC would not see automatically.

That's not what the KVC docs say.

<http://developer.apple.com/documentation/Cocoa/Conceptual/ KeyValueCoding/index.html>

From that page, the first step in the search pattern used by -valueForKey: is: "Search the receiver’s class for an accessor method whose name matches the pattern -get<Key>, -<key>, or -is<Key>, in that order."

I should have done my homework first...
In that case, I don't get it. Where in the documentation does it specify that getKey should be used in the manner Charlton described? And why are we encouraged to implement key instead of getKey, but getKey is searched for first?

I remember the time, when Apple (NeXT at that time) said, that getters should be prepended with "get". Some years later they changed by saying, that you only should take the name of the IVar and the "get" version is reserved for copying the actual value into a reserved memory space. So IMHO, the reason, why KVC is looking also into the "get" version, is due to historic reasons and is definitely not good coding style. Apple might optimize this case away at any time.



Phil


BTW: I also remember the time, where every method was supposed to return "self". This has been stopped, when DO was introduced.
_______________________________________________
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
  • Follow-Ups:
    • Re: loop efficiency & messages
      • From: John Stiles <email@hidden>
    • Re: loop efficiency & messages
      • From: Marco Scheurer <email@hidden>
References: 
 >Re: loop efficiency & messages (From: Will Mason <email@hidden>)
 >Re: loop efficiency & messages (From: Charilaos Skiadas <email@hidden>)
 >Re: loop efficiency & messages (From: Sherm Pendley <email@hidden>)
 >Re: loop efficiency & messages (From: Charilaos Skiadas <email@hidden>)

  • Prev by Date: Re: loop efficiency & messages
  • Next by Date: Re: Cocoa coding style (was loop efficiency & messages)
  • Previous by thread: Re: loop efficiency & messages
  • Next by thread: Re: loop efficiency & messages
  • Index(es):
    • Date
    • Thread