How to store settings on iPhone immediately?

advertisements

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


- (void)compSave
{
    [[NSUserDefaults standardUserDefaults] setInteger: compTotal forKey: @"compTotal"];
    [[NSUserDefaults standardUserDefaults] setInteger: compCount forKey: @"compCount"];
    [[NSUserDefaults standardUserDefaults] setBool: compShow forKey: @"compShow"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}