开发者

Can app preferences be read only on startup?

开发者 https://www.devze.com 2023-02-22 18:08 出处:网络
I have implemented inappsettings to have a preferences view in my application to be able to edit settings.bundle values straight in the app.

I have implemented inappsettings to have a preferences view in my application to be able to edit settings.bundle values straight in the app.

However now I wanted to read from settings.bundle but reading the iOS programming guide I found out that settings.bundle should be read on application startup.

S开发者_C百科o is it not possible to access this preferences any time in my code? Inappsettings would not make any sense if the user could not update preferences any time while the app is running.

Inappsettings offers the method InAppSettings registerDefaults

- (void)initialize{
    if([self class] == [AppDelegate class]){
        [InAppSettings registerDefaults];
    }
}

But I am not sure if that makes it possible to read preferences any time. Any suggestions?

Edit: in my app I have three views, one is the dashboard. The other, a option and a mail view, are shown modally.

In the preferences the user can setup some basic things that I need to send the message. So when the user just started typing and wants to change e.g. the transmission gateway he opens the option view, which is the inappsettings view, and changes some things. I would like to read this changes without restarting the app.


Clearly Apple wants to impose external preferences UI paradigm on us. Please recall how Mail.app works. Sometimes that paradigm makes sense, sometimes doesn't. If you have immutable preference set, you don't have to think about events handling onPrefferenceChange, concurrency, synchronization, OS backup and replication issues,etc... However the facilities that Apple provided are very limited in what they can do. You can't even enter an arbitrary string there (Mail.app clearly uses some private API for that). So you have to make a choice whether you can use what Apple offers or implement your own preference system (may be based on top of NSUSerDefaults or something). I implemented my own once and I use it ever since. I prefer to have a real in-app preference system. The main advantage of that is to able changing its value without leaving an app.

0

精彩评论

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