I have 3 entities in a Core Data application:
Projeto <-->> Servico <-->> Sessao (the relationships are named as usual).
Projeto.servico (to many Projeto --> Servico)
Servico.projeto (inverse to one Servico --> Projeto)
Servico.sessaoDoServico (to many Servico --> Sessao)
Sessao.servicoDaSessao (inverse to one Sessao --> Servico)
Each entity is connected to an array controller, like "Department and employees" in Apple Docs. It's Working fine in a typical Master - details configuration.
Now I want to have all Sessions from a selected Project. (I don't have a relationship between Sessao and Projeto)
I'm trying to bind the SessionArrayController Content Set to filter the sessions without success.
How could I have all sessions for a selected project?
I created a property for the Session Class, returning a NSSet and I can print the desired sessions, but I have no idea, how I could do it with binding.
-(NSSet *)sessoesDoProjeto{
NSSet *allSessions = [self.projeto.servico valueForKey:@"sessaoDoServico"];
NSLog(@"allSessions %@",allSessions);
return allSessions;
}
Could I create a NSArrayController with the above NSSet?
Any help would be appreciated
I found the solution, so I'm posting for others with the same problem.
I bound the Content Array (not content set) of the SessionArrayController to:
ServicoArrayController_by_Project.arrangedObjects.@unionOfSets.sessaoDoServico
It works like a charm!