Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 10-12-2009, 08:28 AM   #12 (permalink)
jbullfrog
Registered Member
 
Join Date: Jun 2009
Posts: 140
jbullfrog is on a distinguished road
Default still not working right

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..
jbullfrog is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 175,282
Threads: 93,959
Posts: 402,308
Top Poster: BrianSlick (7,971)
Welcome to our newest member, kurtwatson
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:27 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.