考慮下面的代碼:的UITextView來計算不工作
這裏是我的價格計算器控制器頭文件。
#import <Foundation/Foundation.h>
#import "PriceCalculator.h"
@interface PriceCalculatorController : UITextField {
IBOutlet UITextField *mpgField;
IBOutlet UITextField *milesField;
IBOutlet UITextField *priceField;
IBOutlet UITextField *ridersField;
IBOutlet UITextField *splitField;
PriceCalculator *calculator;
}
-(IBAction)calculator:(id)sender;
@end
下面是它的實現文件:
#import "PriceCalculatorController.h"
@implementation PriceCalculatorController
- (IBAction)calculator:(id)sender {
float split;
calculator = [[PriceCalculator alloc]init];
[calculator setMpg:[mpgField float]];
[calculator setRiders: [ridersField float]];
[calculator setMiles: [milesField float]];
[calculator setPrice: [priceField float]];
split = [calculator CalculateSplit];
[splitField setFloatValue:split];
}
@end
它給我的錯誤:
receiver type 'UITextField' for instance message does not
declare a method with selector 'float' [4]
這是怎麼回事?