• 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: Clayton Leitch <email@hidden>
  • Date: Sun, 14 Aug 2005 10:41:37 -0400

Well, I found a document that talked about derived in core data, NSPersistentDocumentTutorial.pdf. However, it talks about taking string variables and concatenating them together to give a person's full name. However, it is essentially the same problem that I have. Following the instructions, to the letter, I made a class file from the data modeling interface, an NSManaged object is the superclass.

When I compiled the file I received the errors that are described below:

PNG image

If I uncomment the self setKeys lines I get a selector unrecognized error when I try to run the project. I have tried various means to do the subtraction including the decimalNumberBySubtracting method. All either give me an error or a warning. I also tried primitiveValueForKey with no success.

Any Ideas?
On Aug 14, 2005, at 4:00 AM, mmalcolm crawford wrote:


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


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

  • Prev by Date: Re: Calculated Field examples for Core Data
  • Next by Date: What's wrong with having multiple windows per document in only one nib?
  • Previous by thread: Re: Calculated Field examples for Core Data
  • Next by thread: Re: Calculated Field examples for Core Data
  • Index(es):
    • Date
    • Thread