3つのViewControllerがあり、それぞれにCountというintがあります。カウントはユーザーのハイスコアであり、アプリが強制終了された場合でもそれを保持したいと思います。
これは整数です。
int Count = 100;
ここにスコアが表示されます(ViewDiDLoad内のUILabel)。
scoreCounter.text = @"";
そして、これは私がそれを呼び出すコードです(Inside IBAction);
NSString *numValue = [[NSString alloc] initWithFormat:@"%d", Count--];
scoreCounter.text = numValue;
[numValue release];
基本的にボタンを押すたびにスコアが下がります。上記のコードは、次のように開く3つの異なるビューコントローラーにあります。
if(Count == 90)
{
SecondLevelViewController *screen = [[SecondLevelViewController alloc] initWithNibName:nil bundle:nil];
screen.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentModalViewController:screen animated:YES];
[screen release];
必要なのは、このスコアを保存し、最後に使用されたView Controllerを保存して、スコアが90の場合、アプリがSecondViewControllerを起動するようにする方法です。