开发者

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

开发者 https://www.devze.com 2022-12-23 07:53 出处:网络
I\'ve got application settings working just fine.However, I\'d like to be able to change my app settings from within my app.

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 ge开发者_开发技巧neric 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.

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. 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. The documentation is available here.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号