How To Use Multi Value Title and Value From Settings Bundle How To Use Multi Value Title and Value From Settings Bundle ios ios

How To Use Multi Value Title and Value From Settings Bundle


You should set your "Default Value" value as "1" - Just Item 0 from your "Values" list.


I ran into the similar situation and answering the question that it'll help someone.

If I understand the question correctly, when user selects London from the settings the default value will be 1. when you read the settings bundle for locationSetting you get the value 1 and not LONDON, but you want the "LONDON" in your code rather than 1. It is not possible with the current structure of your plist. make the default value a dictionary instead of string and then you can have both titles and values inside that dictionary. you can then retrieve the text of the selected value.


Location settings as a multi value, is an NSDictionary. Therefore, do the following:

NSDictionary *location = [[NSUserDefaults standardUserDefaults] valueForKey:@"locationSettings"]; NSString *value = (NSString *)location; 

Cast the location value as a NSString because you know a string is to be returned.

You can then handle the result as a string. The "value" variable returned is whatever is written in the value section. In your case, if you select "London", you will get a value of "1" back in the form of a string.