存档&&解档游戏状态

Posted Shell

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了存档&&解档游戏状态相关的知识,希望对你有一定的参考价值。

  • 解档

  

//AppDelegate.m
@synthesize window=_window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
   
    NSString* gameArchivePath = [self gameArchivePath];
    OneGame* existingGame;
    @try {
        existingGame = [[NSKeyedUnarchiver unarchiveObjectWithFile:gameArchivePath] retain];
    }
    @catch (NSException *exception) {
        existingGame = nil;
    }
    [gameController setPreviousGame:existingGame];
    [existingGame release];
    
    //设置为主窗口并显示出来
    [self.window makeKeyAndVisible];
    return YES;
}



//GameController.m
-(void)setPreviousGame:(OneGame*)aOneGame{
    previousGame = [aOneGame retain];
    
    if (previousGame != nil && [previousGame remaingTurns] > 0){
        [continueButton setHidden:NO];
    } else {
        [continueButton setHidden:YES];
    }
}

 

  • 存档

 

以上是关于存档&&解档游戏状态的主要内容,如果未能解决你的问题,请参考以下文章