Pregunta

I'm pretty new to cocoa programing. In a simple master-detail view I want to show:


+-------+ +-----------+ +           +
|       | |           |
| tags  | |   books   |     detail
|       | | (selected |   (selected
|       | |   tag)    |     book)
|       | |           |
+-------+ +-----------+  +          +

I have defined two entities:
tag, with an attribute name and a relationship books
book, with several attributes (title, author, type, date,..) and a many to many relationship tags (one book can have several tags, and one tag can have many books).

Then I define two array controllers (tagsArrayController and booksArrayController). They populate the tables, and the detail view.

The value binding is:
tags tableview column: tagsArrayController arrangedObjects
books tableview column: tagsArrayController selection.details
detail view: booksArrayController selection.details

Everything works.

I want to use the first table (tags) as a filter for the books table: when a row is selected in the tags table, the related books are shown in the books table.

But, when no tag is selected, the filter should be disabled, and the books table should be populated with all the records. Instead, now when no tag is selected, the books table shows no record.

Is there a way to achieve this?

Thanks in advance.

Well, finally I found the solution. I added the method:


-(void)tableViewSelectionDidChange:(NSNotification *)notification

and then used de setFilterPredicate method over the tagsArrayController.

¿Fue útil?

Solución

Well, finally I found the solution. I added the method:

-(void)tableViewSelectionDidChange:(NSNotification *)notification

and then used de setFilterPredicate method over the tagsArrayController.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top