views:

36

answers:

3

Hi...i am new to iPhone programming..

my app is just like a quiz.. it has different type of quizs and many question in each quiz type i want to save the values like strings(quiz name) and integers(question number) when an application is closed so when the app is restarted i want to continue where it was stopped by using saved values

How to do this...?

Can any body help me to do this please....

Thank u

A: 

I would suggest you look at Core data and save answers as they are entered. Then when the app is restarted you need to find a way to quickly load the relevant data (Actually, you will find you don't need to load that much, which could also help you reduce what you need to save.)

Remember, simplicity is of the essence, and lazy loading very helpful. Don't load anything you don't need until you need it.

A good Apple example was the SQLiteBooks sample which they provided with iPhoneOS 2.0 (I don't know if they still provide it).

John Smith
Thank u Smith for the Quick response..i used the NSUseDefaults..Thank u
rockey
A: 

NSUserDefaults is good for saving state and preferences.

drawnonward
Thanks Drawnonward.. for quick response..i used NSUserDefaults...
rockey
+1  A: 

To save a string:

NSString *name = @"John";
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
[prefs setObject:name forKey:@"Name"];

To load a string:

NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
NSString *name = [prefs stringForKey:@"Name"];

Read more at: http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSUserDefaults_Class/Reference/Reference.html

ohho
Thank u Horace..i used it its working...
rockey