• 存档&&解档游戏状态


    • 解档

      

    //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];
        }
    }
    • 存档
    //AppDelegate.m
    //进入后台游戏存档
    - (void)applicationDidEnterBackground:(UIApplication *)application
    {
        NSString* gameArchivePath = [self gameArchivePath];
        [NSKeyedArchiver archiveRootObject:[gameController currentGame] toFile: gameArchivePath];
    }
  • 相关阅读:
    《Hadoop实战》第一章
    找工作必备技能
    范数的深刻解读(转自知乎)
    贝叶斯定理(贝叶斯分类)
    什么是机器学习?
    线性可分 与线性不可分
    正则化和归一化
    过拟合问题是什么?
    CVPR 2016 paper reading (6)
    CVPR 2016 paper reading (3)
  • 原文地址:https://www.cnblogs.com/HackHer/p/8158994.html
Copyright © 2020-2023  润新知