• 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: Core Data Rookie
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Core Data Rookie


  • Subject: Re: Core Data Rookie
  • From: Andrew Shamel <email@hidden>
  • Date: Fri, 22 Jul 2005 08:59:06 -0400


On Jul 21, 2005, at 8:13 PM, mmalcolm crawford wrote:

On Jul 21, 2005, at 4:55 PM, Andrew Shamel wrote:


And one more email from a clueless new Core Data programmer...

My problem is this: I want to create an application that keeps track of recipes. I have done this handily so far, up to the handling of the ingredients. I want the UI to have a column listing the various recipes, and a table listing the ingredients for the selected recipe.

The application's data model contains two entities: Recipe and Ingredient. As it stands now, each entity has a reciprocal relationship to the other, on the order of "recipes" and "ingredients." The relationship from Recipe to Ingredient is one- to-many, and the relationship from Ingredient to Recipe is one-to- one, as a recipe has many ingredients, but each ingredient has only one recipe.

Thus far, I have been able to make the Ingredients table display ALL of the ingredients created, but I am having trouble figuring out how to set an ingredient's recipe relationship to point to the selected recipe, and likewise, how to make the ingredients table display only those that belong to the selected recipe.

My guess is that I lack a sufficient understanding of Core Data. I've looked at any number of Apple documentation pages, and have done Cocoa Dev Central's Core Data tutorial. The trouble is, the tutorial is really just a walk-through, and it doesn't do much in the way of explaining what's actually going on.


This really has very little to do with Core Data. It's a question of how you are controlling your objects. You haven't said how you are managing your table views, how you determine your selection and so on. From this perspective, Core Data managed objects behave in exactly the same way as any other Cocoa objects. If you're using bindings to manage your user interface, simply use your array controller's 'selection' and follow key paths, just as you would non-Core Data objects. An example (that uses Core Data, but an object rather than an array controller) is given in <http:// developer.apple.com/documentation/Cocoa/Conceptual/ NSPersistentDocumentTutorial/index.html>.

An entire "recipes" sample application is given at <http:// developer.apple.com/samplecode/CoreRecipes/CoreRecipes.html>.

mmalc

Thanks so much!

--a
_______________________________________________
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: 
 >Core Data Rookie (From: Andrew Shamel <email@hidden>)
 >Re: Core Data Rookie (From: mmalcolm crawford <email@hidden>)

  • Prev by Date: Re: Copying ABPerson (problem with MultiValue fields)
  • Next by Date: More information about KVC, KVO, and KVB
  • Previous by thread: Re: Core Data Rookie
  • Next by thread: NSTableView column order in Interface Builder
  • Index(es):
    • Date
    • Thread