How to change the app preference settings through code?

情到浓时终转凉″ 提交于 2019-12-21 21:40:08

问题


I have listed my app in the device setting app.Now I can change my app settings through the device app settings app. Now what I am trying to do is the reverse. I am trying to make a app so that it can itself change its preferences in the device settings app if I change the preferences of my app from within the app.

Any ideas Friends, Thank You All.


回答1:


Nice and simple:

[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"MyPreferenceKey"];

NSUserDefaults includes convenience methods for setting ints, floats, strings, and so on. You can also just use -setValue:forKey:.

When you change a value in your app using NSUserDefaults, the setting well change in the Settings app, too.



来源:https://stackoverflow.com/questions/1459275/how-to-change-the-app-preference-settings-through-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!