ナビゲーション コントローラーを実行するときに extern 変数を保存する際に問題が発生します。これは、ポイントを計算するためのコードでゲーム ポイントを計算するアプリです。
これは、ポイントを計算するための IBAction です。
- (IBAction)RedTeloBallsTotal:(id)sender {
NSString *firstString = RedTeloBallsOne.text;
NSString *secondString = RedTeloBallsTwo.text;
NSString *thirdString = RedTeloBallsThree.text;
NSString *fourthString = RedTeloBallsFour.text;
NSString *LEGAL = @"0123456789";
NSCharacterSet *characterSet = [[NSCharacterSet characterSetWithCharactersInString:LEGAL] invertedSet];
NSString *filteredOne = [[firstString componentsSeparatedByCharactersInSet:characterSet]
componentsJoinedByString:@""];
NSString *filteredTwo = [[secondString componentsSeparatedByCharactersInSet:characterSet]
componentsJoinedByString:@""];
NSString *filteredThree = [[thirdString componentsSeparatedByCharactersInSet:characterSet]
componentsJoinedByString:@""];
NSString *filteredFour = [[fourthString componentsSeparatedByCharactersInSet:characterSet]
componentsJoinedByString:@""];
firstString = filteredOne;
secondString = filteredTwo;
thirdString = filteredThree;
fourthString = filteredFour;
//Here we are creating three doubles
double num1;
double num2;
double num3;
double num4;
double output;
//Here we are assigning the values
num1 = [firstString doubleValue];
num2 = [secondString doubleValue];
num3 = [thirdString doubleValue];
num4 = [fourthString doubleValue];
output = num2 + (num1 * 2) + num4 + (num3 * 25);
//Now we are going to display the output in the label.
RedTeloBallsTotal.text = [NSString stringWithFormat:@"%.0f",output];
}