• 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: Cocoa coding style (was loop efficiency & messages)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cocoa coding style (was loop efficiency & messages)


  • Subject: Re: Cocoa coding style (was loop efficiency & messages)
  • From: Mark Dawson <email@hidden>
  • Date: Wed, 23 Mar 2005 10:02:04 -0800

At: http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/Concepts/AccessorConventions.html#//apple_ref/doc/uid/20002174/BAJEDEFB

"Typically, the format for an accessor method that returns a property is <x-tad-bigger>-<key></x-tad-bigger>. The <x-tad-bigger>-<key></x-tad-bigger> method returns an object, scalar or a supported data structure. The alternate naming form <x-tad-bigger>-is<Key></x-tad-bigger> is supported as well."
...
"In order for an attribute or to-one relationship property to support <x-tad-bigger>setValue:forKey:</x-tad-bigger> an accessor in the form <x-tad-bigger>-set<Key>:</x-tad-bigger> must be implemented. Listing 3 shows an accessor method for the <x-tad-bigger>hidden</x-tad-bigger> property key."

Mark


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?

sherm--

Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


Haris

_______________________________________________
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

 _______________________________________________
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

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: Case insensitive autocomplete
  • Previous by thread: Re: loop efficiency & messages
  • Next by thread: Re: loop efficiency & messages
  • Index(es):
    • Date
    • Thread