I somehow got rid of that 264...
And i noticed if I do this
Code:
[[NSUserDefaults standardUserDefaults] setInteger:[high_level.text intValue] forKey:@"high_score"];
Instead of this, as you mentioned stolidimran
Code:
[[NSUserDefaults standardUserDefaults] setInteger:high_level_value forKey:@"high_score"];
I dont get any warnings, but still not savint the high level value.
I am doing this in the game loop,
Code:
//COMPARE CURRENT LEVEL WITH HIGH LEVEL.
if([current_level.text intValue] > [high_level.text intValue]){
high_level.text = current_level.text;
}
And that is working fine, as you play the game its setting the high level to the current level if the current level is greater than the high level.
So im assuming that when the game is closed, the high level value should be saving with this.
Code:
- (void)applicationWillTerminate:(NSNotification *)notification
{
//Save data here
[[NSUserDefaults standardUserDefaults] setInteger:high_level_value forKey:@"high_score"];
[[NSUserDefaults standardUserDefaults] synchronize];
NSLog(@"app quit, save high level");
}
And loading with this when restarting
Code:
- (void)viewDidLoad {
//Load data here
high_level_value=[[NSUserDefaults standardUserDefaults] integerForKey:@"high_score"];
NSLog(@"set high level");
UIApplication *app = [UIApplication sharedApplication];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:UIApplicationWillTerminateNotification object:app];
NSLog(@"check close high level");
[super viewDidLoad];
}
but it just doesnt work..