1. 程式人生 > >存檔&&解檔遊戲狀態

存檔&&解檔遊戲狀態

sdi archiver arch syn elf previous lease launching ict

  • 解檔

  

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

  • 存檔

存檔&&解檔遊戲狀態