开发者

Binding a text field to Shared User defaults controller doesn't use null value

开发者 https://www.devze.com 2022-12-30 09:41 出处:网络
I set the text field to bind with a values controller key, a keypath of spacesPerTab, and setting 4 as the placeholder values. But when executing it, the text field displays nothing.

I set the text field to bind with a values controller key, a keypath of spacesPerTab, and setting 4 as the placeholder values. But when executing it, the text field displays nothing.

This works for checkbox开发者_高级运维es.


The null-placeholder field isn't the correct place to set a default value. It only sets what value will be displayed to the user if no value is set; nothing on the back end will see it.

To truly set a default value, send the standard user defaults object a registerDefaults: message early on in your application. You'll pass a dictionary that contains all of your default values.

You may want to write the dictionary in a plist file, using Xcode or Property List Editor, and bundle it into your application and read it at run time. That will make the code that registers the defaults easier to read for not having a giant hard-coded dictionary in the way.

0

精彩评论

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