Fetching AFIncrementalStore Related Data

117 Views Asked by At

i'm working on an Mac-App using AFIncrementalStore to fetch Data from my REST Api.

My Models look like this:

Customer

- id
- name
- Relation:Projects

Project

- id
- name
- Relation:Customer

In my UI i have to NSComboBoxes, one for the Customers and one for the Projects. The Projects ComboBox is disabled at start.

When I select a Customer in the fist ComboBox, the second ComboBox should only show the related Projects for that Customer.

My Bindings for the ComboBoxes are:

Customer: ArrayController->arrangedObjects->name
Projects: ArrayController->selectedObjects->projects.name

The first ComboBox is working, but how do I get the Second ComboBox to show the related Projects?

On App Launch the following Requests are made:

/api/customers
/api/customers
/api/customers/1/projects
/api/customers/2/projects
/api/customers/1
/api/customers/2
/api/customers/1/projects
/api/customers/1
/api/customers/2
/api/customers/2/projects
/api/customers/2
/api/customers/2/projects
/api/customers/1/projects
/api/customers/1
/api/customers/2/projects
/api/customers/2

Why are there so many requests made some of them twice? I have only 2 Customers in my response.

0

There are 0 best solutions below