views:

19

answers:

1

Working environment: OS X 10.6.3, Xcode 3.2.1
Hi! I'm working on a project called Rent-a-Flick. The project has two entities: Movie and Client. Between them there's a many-to-many relationship.
I have 2 tables: one with the movies and one with the clients. Their content is bound to the proper array controllers(for movie and client).
I want to add a third table in which only the clients that rented a selected movie will appear. I should also be able to add/remove clients from this table. How can I do that without creating duplicates?
The project is open source. I'll publish it as soon as I make a stable release.

A: 

This "third table" already exists implicitly in your Core Data many-to-many relationship.

When you call a method like [aMovie addClientObject:aClient] on one of your Core Data model objects, the effect of that is to add a row to the movie-client relationship table. Similarly, if you want to remove a client, you would do it using the Core Data accessor method [aMovie removeClientObject:aClient], not by directly manipulating the table.

If you have an instance of a Movie object, you can see what clients rented that movie simply by referring to the clients property of that object. For example:

NSArray *rented_clients = [[aMovie.clients] allObjects];
David Gelhar
First of all, thanks for your answer!However, when I try to do that(from the IB: binding the column's value to the Movie Array Controller, Controller Key to arrangedObjects and Model KeyPath to RentedBy.Name) it gives me three "{(" in that column and I can't edit them.Am I doing something wrong?
Phreakazoid