NSUserDefaults用法
1.
存
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setFloat:self.slider.value forKey:kTheSlider];
取
self.sliderValueLabel.text = [[defaults objectForKey:kTheSlider] stringValue];
self.slider.value = [defaults floatForKey:kTheSlider];
2.
存
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setBool:self.theSwitch.on forKey:kTheSwitch];
取
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
self.theSwitch.on = [defaults boolForKey:kTheSwitch];
3.
存
[[NSUserDefaultsstandardUserDefaults] setObject:shopperAddress.shopperNameforKey:@"kReceiverName"];
取
receiverOneName = [[NSUserDefaultsstandardUserDefaults] objectForKey:@"kReceiverName"];
存
[[NSUserDefaultsstandardUserDefaults] setObject:shopperAddress.shopperNameforKey:@"kkReceiverNameTwo"];
取
((UILabel *)[shopCarCell viewWithTag:601]).text = [[NSUserDefaultsstandardUserDefaults] objectForKey:@"kkReceiverNameTwo"];