Core Data - 'calculated' attributes
- by nephilim
I have two entities: A and B
A has two properties from and to, both pointing to the B entity.
B as a fetched property to A with predicate from == $FETCH_SOURCE or to = $FETCH_SOURCE
-- (from) ->
A -- (to) -> B
<- (As) --
In my application I select a certain B instance, and then show all of its A instances.
Now, in my table the columns are bound to an array controller containing the selected A instances.
I want to 'merge' the from and to columns. I already know one of the columns will be equal to the selected B instance, so now I'm only interested in the second value.
The options I see:
create a custom class for the B entity and create a method that returns either value. It should somehow be able to retrieve which B instance is currently selected.
create a custom DataSource. Most columns are still using bindings, so then we'd have to access the NSArrayController's array so we're sure we have the right object.
create a custom DataSource, remove the NSArrayController and do all the Core Data stuff ourselves.
Is there any 'right' way to solve this?