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"];

 

 

 

posted on 2012-06-06 14:06  一梦浮生2012  阅读(1437)  评论(0编辑  收藏  举报