2013-08-29 14 views
-2

我是新来的,所以任何帮助将不胜感激。在此先感谢我如何修复“预期表达”

IBOutlet UITextField *textField1; 
IBOutlet UITextField *textField2; 
IBOutlet UILabel *label1; 
@end 

.M

-(IBAction)calculate {       **This is the line with the problem** 
int x = ([textField1.text floatValue]); 
int c = x*([textField2.text floatValue]); 
    [super viewDidLoad]; 
// Do any additional setup after loading the view, typically from a nib. 
- (void)didReceiveMemoryWarning 
{ 
    [super didReceiveMemoryWarning]; 
// Dispose of any resources that can be recreated. 
} 
@end 

回答

1

坦率地说,它看起来.H就像一颗炸弹在您的实现去了。首先,你似乎错过了.m开头的@implementation指令。然后,你可以在IBAction中调用[super viewDidLoad];,当它应该在你缺少的viewDidLoad方法中。

另外,在IBAction结束时,您从未添加过大括号}

你的.h文件中应该是这样的:

#import <UIKit/UIKit.h> 

@interface ViewController : UIViewController 
{ 
    IBOutlet UITextField *textField1; 
    IBOutlet UITextField *textField2; 
    IBOutlet UILabel *label1; 
} 
@end 

您的m应该是这样的:

#import "ViewController.h" 

@implementation ViewController 

- (IBAction)calculate { 
    int x = ([textField1.text floatValue]); 
    int c = x*([textField2.text floatValue]); 
} 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view, typically from a nib. 
} 

- (void)didReceiveMemoryWarning 
{ 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 

@end 
+0

它仍然表示,它预计在表达式 - (IBAction为)计算{线和我失踪@end ???? – user2728373

+0

是的......但我不知道为什么xcode认为我错过了@end它在那里? – user2728373

+0

缺少界面? – user2728373