Storing results after screen is disappear

后端 未结 2 1773
后悔当初
后悔当初 2020-12-12 07:50

I am developing a game,in that i want to add the points continuously,for this i used plist but whenever the screen is disappear and starts then plist starts again.what to do

2条回答
  •  無奈伤痛
    2020-12-12 08:06

    You can make AppDelegate variables and store it in them. There scope remains in the complete application until the application closes.

    In AppDelegate.h for example

    NSString *string;
    
    @property(nonatomic, strong) NSString *string;
    

    In AppDelegate.m

    @synthesize string;
    

    in applicationDidFinishLaunchingWithOptions

    string = @"";
    

    And then is your classes add #import "AppDelegate.h"

    then in your code ((AppDelegate *)[UIApplication SharedApplication].Delegate).string = @"1";

提交回复
热议问题