1

設定ページが必要なアプリを作成しています。どちらが別のクラスになるので、あるクラスから別のクラスにデータを渡すにはどうすればよいですか? 例: 設定ページに UISwitch があり、ユーザーが別のクラスで選択したオプションを確認する必要があります。

ありがとう。

4

1 に答える 1

3

設定ページで、次のコードを使用して設定を同期します -

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.

これがお役に立てば幸いです!

于 2010-08-18T16:24:18.153 に答える