码迷,mamicode.com
首页 > 其他好文 > 详细

存档&&解档游戏状态

时间:2017-12-31 22:29:42      阅读:195      评论:0      收藏:0      [点我收藏+]

标签:ons   bsp   arch   rem   elf   archive   release   ret   窗口   

  • 解档

  

//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];
    }
}

 

  • 存档

 

存档&&解档游戏状态

标签:ons   bsp   arch   rem   elf   archive   release   ret   窗口   

原文地址:https://www.cnblogs.com/HackHer/p/8158994.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!