0
我在保存開關位置時遇到一些問題,有什麼幫助嗎?NSuserdefaults UISwitch
- (IBAction)SWitchActionAño:(id)sender {
NSUserDefaults *standardDefaults = [NSUserDefaults standardUserDefaults];
if (switchAño.on) {
[standardDefaults setBool:YES forKey:@"SwitchState"];
NSDateFormatter *formatter=[[NSDateFormatter alloc]init];
[formatter setDateFormat:@"MMM dd,yyyy HH:mm"];
diadelasemanalabel.text=[formatter stringFromDate:[NSDate date]];
} else {
[standardDefaults setBool:NO forKey:@"SwitchState"];
Añ[email protected]"";
}
}
但我在這裏有問題!我不知道什麼是財產!
- (void)viewDidLoad
{
[super viewDidLoad];
NSUserDefaults *standardDefaults = [NSUserDefaults standardUserDefaults];
//the error here:property switchAño not found on object....
if ([standardDefaults objectForKey:@"SwitchState"])
self.switchAño.on =[standardDefaults boolForKey:@"SwitchState"];
同樣同樣的問題,當我使用sel.switch財產....改變。爲 - ) – Mark93