开发者

Sharing parameters between setting view and application view

开发者 https://www.devze.com 2022-12-29 18:19 出处:网络
Simple question : I\'ve got an iPhone app with 2 views with each a separated xib files. one view holds the settings of the app

Simple question : I've got an iPhone app with 2 views with each a separated xib files. one view holds the settings of the app one view holds the app using the settings made in previous view.

How should I implement the sharing of setup p开发者_JS百科arameters between the 2 views ? should I manage those parameters in the app delegate ?


You can save the settings in the user defaults using

[[[NSUserDefaults] standardUserDefaults] setObject:blah forKey:@"blah"];

Then in the other view, just get the values from the user defaults with

[[NSUserDefaults] standardUserDefaults] objectForKey:@"blah"];

The NSUserDefaults class keeps the objects in memory and writes them out to disk at certain periods. So you don't have to worry about hitting the disk too often.

0

精彩评论

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