• 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: When to use key-value coding to get values vs. accessors
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: When to use key-value coding to get values vs. accessors


  • Subject: Re: When to use key-value coding to get values vs. accessors
  • From: Paul Bruneau <email@hidden>
  • Date: Fri, 2 Nov 2007 08:19:10 -0400

On Nov 1, 2007, at 5:04 PM, mmalc crawford wrote:

On Nov 1, 2007, at 1:29 PM, Paul Bruneau wrote:

Not looking for an in-depth explanation (I should be able to find/ understand the docs once I get tipped in the right direction), but can someone briefly hint to me the reason Apple uses key-value coding in this example code:
http://developer.apple.com/documentation/Cocoa/Conceptual/ NSPersistentDocumentTutorial/03_CustomClass/chapter_4_section_3.html


Because, for brevity, the tutorial didn't show the implementation of the custom accessors.

For current best practice, see <http://developer.apple.com/ documentation/Cocoa/Conceptual/CoreData/Articles/ cdAccessorMethods.html>.

Feel free to file an enhancement request to ensure this is covered in an update to 10.5 for that tutorial.

I thank you for your reply, but I think your reply was aimed at a higher level than I meant to ask it.


Please let me add some information. I am developing in and for 10.4 at this time. I am just using basic Cocoa with Bindings. I am not using Core Data or Managed Objects (I don't think!).

So my question is, do I have any reason to use valueForKey (like the example I referred to uses) or am I OK using the simple primitive accessors?

I am interested in doing things Rightâ„¢ like being KVC/KVO compliant, but it's just that I am not sure what would spur me to use - valueForKey: rather than just [myObject myInstanceVariable]

OK, I just re-found http://developer.apple.com/documentation/Cocoa/ Conceptual/ModelObjects/Articles/moAccessorMethods.html#//apple_ref/ doc/uid/TP40002132-SW1

It seems to answer my question that unless I am using Core Data, I can stick with the simple accessor methods. Maybe someone could just verify that if it's true. For example, maybe there are reasons for me to go ahead and use things like -valueForKey even though today I am not using Core Data. This is where my ignorance lies.

Thank you_______________________________________________

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


References: 
 >When to use key-value coding to get values vs. accessors (From: Paul Bruneau <email@hidden>)
 >Re: When to use key-value coding to get values vs. accessors (From: mmalc crawford <email@hidden>)

  • Prev by Date: objectsForXQuery: can return Foundation objects?
  • Next by Date: Re: [NSOutlineView outlineView:isGroupItem] rendering issue
  • Previous by thread: Re: When to use key-value coding to get values vs. accessors
  • Next by thread: re: When to use key-value coding to get values vs. accessors
  • Index(es):
    • Date
    • Thread