ユーザーにテキスト ボックスに数字を入力してもらいます。この数値を計算に使用したい。どうすれば変数に入れることができますか?これまでのところ、私は次のものしか持っていません:
NSInteger *answer = results........
ユーザーにテキスト ボックスに数字を入力してもらいます。この数値を計算に使用したい。どうすれば変数に入れることができますか?これまでのところ、私は次のものしか持っていません:
NSInteger *answer = results........
intValue
またはクラスintegerValue
から使用します。NSString
int answer = [myTextField.text intValue];
また
NSInteger answer = [myTextField.text integerValue];
floatValue
とdoubleValue
を浮動小数点入力に使用することもできます。
NSInteger answer = [textField.text integerValue];
また
int answer = [textField.text intValue];