Set value in CoreData with three related NSPopUpButton
Asked Answered
F

1

13

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"?

Fry answered 8/5, 2012 at 19:47 Comment(2)
Can you post a bit more code at the View-controller level? To persist changes back to your entity you need to send save to the NSManagedObjectContext at some point but I suspect you're doing that.Heliopolis
Do you need to return the managed object, or just return the data in another class that has the data you need?Fylfot
F
1

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.

Fylfot answered 26/8, 2012 at 22:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.