Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
制作应用内设置页面(iPhone)_Iphone_Objective C_Application Settings - Fatal编程技术网

制作应用内设置页面(iPhone)

制作应用内设置页面(iPhone),iphone,objective-c,application-settings,Iphone,Objective C,Application Settings,我正在制作一个需要设置页面的应用程序。这将是一个不同的类,那么如何将数据从一个类传递到另一个类呢?例如:设置页面上有一个UI开关,我需要查看用户为另一个类选择了什么选项 谢谢。在设置页面上,使用以下代码同步设置- NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [defaults setObject: data forKey: @""]; // The forKey is the name of the sett

我正在制作一个需要设置页面的应用程序。这将是一个不同的类,那么如何将数据从一个类传递到另一个类呢?例如:设置页面上有一个UI开关,我需要查看用户为另一个类选择了什么选项


谢谢。

在设置页面上,使用以下代码同步设置-

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject: data forKey: @""]; // The forKey is the name of the setting you're going to sync
[defaults synchronize];
要获取其他控制器中的设置值,请使用以下命令-

NSString *settingValue = [[NSUserDefaults standardUserDefaults] objectForKey: @""]; // The objectForKey is the name of the setting you're getting the value for.

希望这对你有帮助

我强烈建议使用InAppSettings为您创建设置屏幕:它使用NSUserDefaults保存数据,只需读取settings.bundle文件。