• 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: Calculated Field examples for Core Data
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Calculated Field examples for Core Data


  • Subject: Re: Calculated Field examples for Core Data
  • From: mmalcolm crawford <email@hidden>
  • Date: Sun, 14 Aug 2005 01:00:43 -0700


On Aug 13, 2005, at 4:49 AM, Clayton Leitch wrote:

I am using cocoa bindings to display everything now. As I said everything works perfectly and I use Core Data to manage the data store. The first thing I tried was to look at if there was some way to access the data values in the various fields. This led me to the custom accessor page on Apple's site. However, when I attempted to get value for key on the various elements of the managed objects in the core data structure, I was never able to have the value appear.

How are you trying to retrieve a value? This document <http:// developer.apple.com/documentation/Cocoa/Conceptual/CoreData/Articles/ cdAccessorMethods.html#//apple_ref/doc/uid/TP40002154> shows how to write accessor methods, but also states,
"There is no need to write custom accessor methods for properties that are defined in the entity of a managed object’s corresponding managed object model. You can access properties using standard key- value coding methods such as valueForKey:."



Next I considered that I needed a controller object to retrieve the values.

If you're using bindings, then you should use a controller to mediate between your user interface and the managed objects.

I was unsuccessful there too. Then I thought if there was an example available that showed this type of operation, that might give me an idea. To google I went. I found several code fragments but nothing that represented a complete project. How do I access the elements of the managed objects with value for key?

id attributeValue = [anObject valueForKey:@"attributeName"];

This is given in numerous places in the documentation.

Again, none of this though is specific to Core Data, it's general to Cocoa and Cocoa Bindings -- for examples see <http:// developer.apple.com/documentation/Cocoa/Conceptual/CocoaBindings/ index.html>. For more about key-value coding, see <http:// developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/ index.html>, and for key-value observing see <http:// developer.apple.com/documentation/Cocoa/Conceptual/KeyValueObserving/ index.html>, in particular "Registering Dependent Keys" -- for a Core Data-based example, this may be useful: <http://developer.apple.com/ documentation/Cocoa/Conceptual/NSPersistentDocumentTutorial/ 03_CustomClass/chapter_4_section_3.html>.

mmalc



_______________________________________________
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: Calculated Field examples for Core Data
      • From: Clayton Leitch <email@hidden>
References: 
 >Calculated Field examples for Core Data (From: Clayton Leitch <email@hidden>)
 >Re: Calculated Field examples for Core Data (From: mmalcolm crawford <email@hidden>)
 >Re: Calculated Field examples for Core Data (From: Clayton Leitch <email@hidden>)

  • Prev by Date: Re: Core Data questions re: primary keys and modeling tool
  • Next by Date: WORKAROUND: How to create two separate in-memory stores?
  • Previous by thread: Re: Calculated Field examples for Core Data
  • Next by thread: Re: Calculated Field examples for Core Data
  • Index(es):
    • Date
    • Thread