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, 12:37 PM   #13 (permalink)
jbullfrog
Registered Member
 
Join Date: Jun 2009
Posts: 140
jbullfrog is on a distinguished road
Default

Ok, one small step for my app, one big step for me!

After thinking some more I solved my issue! I wasnt declaring the NSUserDefaults in the .h, so I set this in the ViewController.h
Code:
NSUserDefaults *prefs;
@property (nonatomic, retain) NSUserDefaults *prefs;
and in the ViewController.m

Code:
- (void)viewDidLoad {

	self.prefs = [NSUserDefaults standardUserDefaults];
	
	// Check to see what was stored in the user prefs, and update the label with that colour.
	if ([prefs stringForKey:@"high_score"]) {
		NSLog(@"The prefs is set.");
		high_level.text = [prefs stringForKey:@"high_score"];
	}

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

	 - (void)applicationWillTerminate:(NSNotification *)notification
	{
		
		//Save data here
		[[NSUserDefaults standardUserDefaults] setInteger:[high_level.text intValue] forKey:@"high_score"];
		
		[[NSUserDefaults standardUserDefaults] synchronize];
		NSLog(@"app quit, save high level");
	}
Thanks for all the help
jbullfrog is offline   Reply With Quote
 

» Advertisements
» Online Users: 887
21 members and 866 guests
7twenty7, ADY, azertyle, bkdbkd, brainspoon, BrianSlick, dacapo, givensur, IOOIOIO, jangus, john love, Kronokrator, LegionMD, LooN3y, Meoz, mer10, mohamed khairy hassa, pipposanta, reficul, Robiwan, Today's Posts
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,283
Threads: 93,959
Posts: 402,308
Top Poster: BrianSlick (7,971)
Welcome to our newest member, bkdbkd
Powered by vBadvanced CMPS v3.1.0

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