1

I'm looking for best way to populate UIPickerView with data from webservice. I have web service: Country1Country1CODE Country2Country2CODE Country3Country3CODE

I made all parsing correct and i can reach all values of service like service.country or service.code.

Problem is what in UIPickerView I need to show list countries, but return as value selected country code. (i hope i explained understandable). All day i was looking for best way how to do it, but I didn't found nothing... Thanks for you help and wasted time :)

1 Answer 1

1

Once you've retrieved the data from the web server, your best bet is to use an NSDictionary as a repository for the data, which you'd use to store the country codes as objects with the country name as the key.

i.e.: ... dictionaryWithObject:@"826" forKey:@"United Kingdom"

You could then use the NSDictionary allKeys method to obtain an NSArray of country names to populate the UIPickerView with and (once the user has selected a country) can trivially retrieve the corresponding country code via the NSDictionary objectForKey method.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.