简体   繁体   English

有没有一种简单的方法可以从应用程序内部更改iPhone应用程序设置?

[英]Is there an easy way to change iPhone Application Settings from within an application?

I've got application settings working just fine. 我的应用程序设置运行正常。 However, I'd like to be able to change my app settings from within my app. 但是,我希望能够从我的应用程序中更改我的应用程序设置。

It seems as though there should be some kind of generic way to add this functionality to my app without having to recreate all the controls myself. 似乎应该有某种通用的方法可以将此功能添加到我的应用程序中,而不必自己重新创建所有控件。 I mean, the code is already written in apple's settings app. 我的意思是,代码已经在Apple的设置应用中编写了。

Maybe someone wrote this code and open sourced it? 也许有人编写了此代码并将其开源? (if it is not already available) (如果尚不可用)

I prefer my own Settings class as I don't like to write the same stuff again and again. 我更喜欢自己的Settings类,因为我不想一次又一次地写同样的东西。 Therefore I am using a method like ... 因此,我正在使用类似...的方法

- (void) setValue:(id)value forKey:(NSString *)aKey {
    [[NSUserDefaults standardUserDefaults] setObject:value forKey:aKey];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

and fetching would be ... 而获取将是...

- (id) valueForKey:(NSString *)aKey {
    return [[NSUserDefaults standardUserDefaults] valueForKey:aKey];
}

A lot of people have thought the same; 很多人也有同样的想法。 file a bug with Apple, and maybe eventually they'll listen. 向苹果提出错误,也许最终他们会听。

I believe you're looking for NSUserDefaults. 我相信您正在寻找NSUserDefaults。 The documentation is available here . 该文档可在此处获得

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM