Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set value in CoreData with three related NSPopUpButton

I hope to express myself with appropriate terms.

I have three entities: customer, country, state. Between country and state, there are two relationships. So I can create a number of countries and select one of these I can create a number of states that belong to it.

For creating the interface of the entity "customer" I put threeNSPopUpButton's:

  • The first selects the country,
  • The second shows the states related to the selected country.
  • The last shows the zip code related to the chosen state.

My problem is that I can not pass data through the chosenNSPopUpButton entity "customer". The NSPopoUpButton works by binding:

  • Content (bind to:country, arrangedObjects),
  • Content Values (bind to:country, arrangedObjects, model key:country),
  • Selected Index (bind to:country, selectionIndex).

What can I do to ensure that the data selected by the three NSPopUpButton's are recorded in the appropriate fields of the entity "customer"?

like image 921
Andrea Avatar asked May 08 '12 19:05

Andrea


1 Answers

It would seem that using 3 popups may work with your problem here, as you can return the int for each selected item, and then pass that information on to the next button press.

So, when they press 'country', return back the country id, and put that in your customer entity.

Then, when they press state, pass the country to this popup, and show the states, and pass the state id back, and do the same for city.

This way you don't have lots of managed objects around, as you really don't need the data, you just need the id, and perhaps the name, to show to the user, and these can be passed back in a notification back to your controller.

like image 74
James Black Avatar answered Oct 04 '22 16:10

James Black