问题
I have an app where Location is important. Currently I have a multi-value setting in the settings bundle where I have 5 locations defined. The problem with this approach is that the settings bundle is static - i.e. I cannot update that from a JSON list on my server as far as I know.
I want to update the location list from a dynamic list on the server.
I have looked at InAppSettingsKit but this also uses the standard settings bundles. Is it possible to use InAppSettingsKit to import settings updates dynamically from a remote list.
Are there other ways to do what I am trying to do?
回答1:
You won't be able to change the list dynamically with regards to Settings.app. Settings.app always uses the static schema plist from your app bundle. (You could resort to a freeform text field but that probably doesn't catch your case.)
With InAppSettingsKit, you can accomplish that but you have to do some extra work: For the dynamic parts, you'll want to use a custom view controller, e.g. a table view controller.
回答2:
Best way for you handle this is storing the multi-values in the NSUserDefaults and start using them. In this method, you will be able to update the values as well as it will be persistent across multiple sessions.
Edit (answers comment):
Saving it to user defaults.
NSDictionary *appDefaults = [NSDictionary dictionaryWithObjectsAndKeys:
@"your Object", "Your Key"
nil];
[[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults];
[[NSUserDefaults standardUserDefaults] synchronize];
Retriving it:
[[NSUserDefaults standardUserDefaults] integerForKey:@"Your Key"];
来源:https://stackoverflow.com/questions/16102431/dynamic-in-app-settings