在delegate中
- (void)applicationDidFinishLaunching:(UIApplication *)application { //从用户设置中读取上一次的设置 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; isBlur = [defaults boolForKey:kBlurValue]; openVoice = [defaults boolForKey:kVoiceValue]; level = [defaults objectForKey:kLevelValue]; countTime = [defaults integerForKey:kCountTime]; highFirst = [defaults floatForKey:kHighFirstScore]; midFirst = [defaults floatForKey:kMidFirstScore]; beginFirst = [defaults floatForKey:kBeginFirstScore]; } - (void)applicationWillTerminate:(UIApplication *)application { //保存用户设置 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [defaults setBool:isBlur forKey:kBlurValue]; [defaults setBool:openVoice forKey:kVoiceValue]; [defaults setObject:level forKey:kLevelValue]; [defaults setInteger:countTime forKey:kCountTime]; [defaults setFloat:highFirst forKey:kHighFirstScore]; [defaults setFloat:midFirst forKey:kMidFirstScore]; [defaults setFloat:beginFirst forKey:kBeginFirstScore]; }
具体见HitBean