我收到錯誤:Objective-C的無效操作數的二進制表示
invalid operands to binary expression ('UITextField')
我的.h看起來是這樣的:
@interface ViewController : UIViewController{
IBOutlet UILabel *resultLabel;
float result;
IBOutlet UITextField *miles;
IBOutlet UITextField *mpgLoaded;
IBOutlet UITextField *mpgEmpty;
IBOutlet UITextField *fuelCost;
IBOutlet UITextField *payment;
}
-(IBAction)result:(id)sender;
-(IBAction)reset:(id)sender;
@end
和錯誤從計算我想未來做.M:
-(IBAction)result:(id)sender{
result = payment - ((miles/mpgLoaded)*fuelCost)-((miles/mpgEmpty)*fuelCost);
resultLabel.text = [NSString stringWithFormat:@"%.2f",result];
}