Search code examples
objective-ccocoacore-dataosx-mountain-lionxcode4.5

Core data relationships: popup button can select a relationship but the name is not displayed


After a lot of time wasted due to a core data relationship fault, now I'm able to bind a popup button cell to an entity relationship.
The only problem now is that when I select and browse all the options the names are displayed, but when I choose the relationship and click on it, the name disappears.
The entities are very simple:

Entities

So a person can have 0 or 1 home, a home can have 0 to N people (inverse relationship).
I have an array controller named "people" which is in entity mode, bound with the people objects of managed object context.Same for "homes", which is bound with the homes objects.All the names in the table views are displayed correctly, except for the popup button.This is what I see when it's selected:

Popup button

And this is what I see when it's not selected:

Popup button

So like you see the cell is empty.The popup button's bindings are:

1. Content: "homes" arranged objects;
2. Content values: "homes" arranged objects.name;
3. Selected object: "people" selection.home .

So coming to the question: why does not the popup button display the relationship name when it's not selected?

PS: The table view is cell based.


Solution

  • That has been a pain to me, and lastly I solved it so there's the explanation for who will find my same problem: I was mixing view based table views with cell based table views.If you want to bind a cell based table view, do not bind the table view content to the managed object context, but bind it's columns.For the popup button I cancelled all bindings and bound it's column this way:

    1. Content: "homes" arranged objects;
    2. Content values: "homes" arranged objects.name;
    3. Selected object: "people" selection.home .

    So this may seem the same, but now is the table column to have these bindings, not the button cell.And now all works fine.