Is it possible to store settings on the iPhone immediately? The apps on iOS 4+ don't close on exit, and if I press 'Stop process' in Xcode settings are not saved? How to save them?
- (void)compLoad {
compTotal = [[NSUserDefaults standardUserDefaults] integerForKey: @"compTotal"];
compCount = [[NSUserDefaults standardUserDefaults] integerForKey: @"compCount"];
compShow = [[NSUserDefaults standardUserDefaults] boolForKey: @"compShow"];
}
- (void)compSave {
[[NSUserDefaults standardUserDefaults] setInteger: compTotal forKey: @"compTotal"];
[[NSUserDefaults standardUserDefaults] setInteger: compCount forKey: @"compCount"];
[[NSUserDefaults standardUserDefaults] setBool: compShow forKey: @"compShow"];
}
[[NSUserDefaults standardUserDefaults] synchronize];
synchronize - this method is automatically invoked at periodic intervals, use this method only if you cannot wait for the automatic synchronization (for example, if your application is about to exit) or if you want to update the user defaults to what is on disk even though you have not made any changes.