• 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, bindings & to-many relationship
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Core Data, bindings & to-many relationship


  • Subject: Re: Core Data, bindings & to-many relationship
  • From: Wain <email@hidden>
  • Date: Tue, 13 Dec 2005 23:13:45 +0000

Hi,

It sounds like you have two controllers, both bound to the managed object context
and both finding all of the appropriate entity's (Trip and Transaction respectively).

What it sounds like you actually want is one controller bound to the managed
object context for Trip entities, and a second controller bound to the selection
of the first controller, rather than the managed object context.
This binding should probably be made to the "contentSet" binding of the second controller,
bind to the first controller with a model key path something like "selection.transactions".

I thought this was in the apple bindings docs but I can't find it quickly (so I'm probably wrong)...

this: http://cocoadevcentral.com/articles/000080.php will do nicely though.
(check out the setup of the mailboxes array controller about half way down the article).

Wain

On 13 Dec 2005, at 22:51, Paul Gribble wrote:

I am writing a little toy app using Core Data to keep track of my expenses
when I travel. I have a "Trip" entity with attributes like dateStart,
dateEnd, location, purpose, etc. I have the interface for this working, of
course it's not that difficult.

What I want to do next is have a list of "transactions" for each trip that
keep track of money spent. Each transaction would have a date, amount, and
purpose.

I have tried creating a "Transaction" entity in the data model, and
connecting the "Trip" entity to it using a to-many relationship, and the
inverse connection back to "Trip" using a to-one relationship.

The problem I am running into now is that in my GUI I can see a list of ALL
transactions for all trips, but how do I make my NSListView only display
transactions for the currently selected Trip?

I have read all of the Apple tutorials on core data and bindings and I am
still at a loss.

Thanks for any suggestions,


PS I also thought of doing the following: write a custom "Trip" class that
has as one of its instance variables an NSArray that would then contain my
"transactions" for the particular trip. This would sidestep core data
however and I thought, there must be a way to do this using core data.



___________________________________________________________ Yahoo! Exclusive Xmas Game, help Santa with his celebrity party - http://santas-christmas-party.yahoo.net/
_______________________________________________
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, bindings & to-many relationship (From: Paul Gribble <email@hidden>)

  • Prev by Date: Re: Setting initial filename for Save As
  • Next by Date: Re: NSAppleScript init is really, really slow when attached to gdb?
  • Previous by thread: Core Data, bindings & to-many relationship
  • Next by thread: Re: Core Data, bindings & to-many relationship
  • Index(es):
    • Date
    • Thread