views:

21

answers:

2

Hi all,

I'm developping a little DB book management Mac OSX app with CoreData and DataBindings. I have a TableView with all the book authors. I would another TableView that rapresent all books written by the author selected in the previous table... The both tables are managed with two ArrayController in IB. My problem is that I don't know how to filter the second table / ArrayController with the first table selection. I must also insert a new book in the filtered ArrayController.

I can do it? Thanks a lot!

A: 

You should read about NSPredicate, array controllers supports them for filtering the content. To add a new book you should override "add:" method of the ArrayController (subclass it) or write a custom method somewhere in the window controller that will construct new object and push it into the ArrayController with addObject: call.

Gobra
+1  A: 

I actually wrote a tutorial that might be of help http://themikeswan.wordpress.com/2009/05/22/7/ the short answer is that you bind the array controller for the book table to get it's Content Set from the selection of the other array controller. The book array controller would then get it's items from whichever author is selected in the author array controller. You should also just have to add a button for adding books and connect it to the book array controller's add: method (I have not tried this as of yet, but in theory it should work, I'm not sure if the author relationship will get properly set though).

theMikeSwan
Thanks. I will read your tutorial ;)
BossOz