iphone - Storing results after screen is disappear -


i developing game,in want add points continuously,for used plist whenever screen disappear , starts plist starts again.what do?

thanks in advance.

to add more info ahmed's answer should implement in appdelegate.m 3 methods this:

appdelegate.h

nsnumber *gamescore;  @property(nonatomic, strong) nsnumber *gamescore;   #define uiappdelegate \    ((appdelegate *)[uiapplication sharedapplication].delegate) 

appdelegate.m

@synthesize gamescore;  - (bool) checkfirstrun {     nsuserdefaults *defaults = [nsuserdefaults standarduserdefaults];     nsnumber *defaultcheck;     defaultcheck = [defaults objectforkey:@"gamescore"];     if (defaultcheck==nil) {         return true;     } else {         return false;     } }  - (void) storeglobalvars {     nsuserdefaults *defaults = [nsuserdefaults standarduserdefaults];     [defaults setobject:gamescore forkey:@"gamescore"];     [defaults synchronize]; }  - (void) readglobalvars {     nsuserdefaults *defaults = [nsuserdefaults standarduserdefaults];     gamescore = [defaults objectforkey:@"gamescore"]; }   - (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions // ...     if ([self checkfirstrun]) {     // first run, lets create basic default values          gamescore = [nsnumber numberwithint:0];         [self storeglobalvars];     } else {         [self readglobalvars];           } // ... 

later in application, after importing appdelegate.h can use uiappdelegate.gamescore access appdelegate's property.

and have remember gamescore nsnumber object, have manipulate using nsnumber's numberwithint and/or intvalue.

the checkfirstrun needed because user's device @ application first run doesn't contain default plist , initial values, have create initial set.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -