@implementation ViewController
-(IBAction)ReturnKeyButton:(id)sender {
[sender resignFirstResponder];
}
@synthesize torque, horsepower, rpm, rpmf2;
-(IBAction)Operation1:(id)sender {
float result = 2 * 3.14 *([torque.text floatValue] * [rpm.text floatValue]) / 33000;
answer1.text = [[NSString alloc] initWithFormat:@"%2.f", result];
}
-(IBAction)Operation2:(id)sender {
float result = 2 * 3.14 * ([horsepower.text floatValue] * [rpmf2.text floatValue]) / 33000;
answer2.text = [[NSString alloc] initWithFormat:@"%2.f", result];
}
テキスト フィールドを数値にフォーマットしたいと考えています。これは機能しますが、私の埋め込みの answer1.text と answer2.text に警告サインがあります。問題は、スレッド ポイントが最終的に破損することです。これの何が問題なのですか?
編集:
@interface ViewController : UIViewController {
float result;
IBOutlet UILabel *answer1;
IBOutlet UILabel *answer2;
IBOutlet UITextField *torque;
IBOutlet UITextField *rpm;
IBOutlet UITextField *horsepower;
IBOutlet UITextField *rpmf2;
int currentOperation1;
float torque1;
float rpm1;
float horsepower1;
float rpm1f2;
float answer5;
}
-(IBAction)Operation1:(id)sender;
-(IBAction)Operation2:(id)sender;
@property(nonatomic, retain) IBOutlet UITextField *torque;
@property(nonatomic, retain) IBOutlet UITextField *rpm;
@property(nonatomic, retain) IBOutlet UITextField *horsepower;
@property(nonatomic, retain) IBOutlet UITextField *rpmf2;
-(IBAction)ReturnKeyButton;
@end