问题
Is it possible to specify validation rules for a particular entry in a Settings.bundle? For instance, would it be possible to restrict a text field to a particular set of characters? Or do I have to alert the user if there is "garbage" in the configuration?
回答1:
I believe you'll have to alert the user that they entered bad data. There isn't any way to add your own code to the settings bundle beyond the plist values.
回答2:
Boy, this is an old question, and...boy, things haven't improved.
The settings metaphor -where Apple recommends that you stick ALL your app settings, BTW- is a usability train wreck.
For example, I needed to add a discrete set of integers as a range of values (1 - 7). The default is an Int.
Looks like the only UI element available is a slider.
With continuous range, and no markings.
Oh, well. There's no way in hell that I'd ever use this as a place to put general-purpose app settings; only rather obscure ones that hardly ever need to be tweaked.
来源:https://stackoverflow.com/questions/8690887/settings-bundle-input-validation