期望的标识符或'(' - xCode

时间:2013-01-11 16:57:18

标签: xcode

我是一名正在为我的学校学习和制作应用程序的学生。我刚刚开始,我做得很好。但是,我收到错误“预期的标识符或'('”。我已经花了几天时间阅读帖子和googleing,我找不到任何解决方案对我有效。

我正在尝试在我的应用程序的第二个标签上创建一个圆形矩形按钮,以链接到学校的网站。

这是.h:

#import <UIKit/UIKit.h>

@interface SecondViewController : UIViewController  {

}


- (IBAction)Website:(id)sender;



 @end

这是我的.m,错误评论:

#import "SecondViewController.h"

@interface SecondViewController ()

@end

@implementation SecondViewController 

-(IBAction)Website {
[[UIApplication sharedApplication ] openURL:[NSURL URLWithString:@"http://www.google.com"]];

}


{      **// Error is on this line[23]**
[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.
}


- (IBAction)Website;


- (IBAction)Website:(id)sender; {
}
@end

我该如何解决这个小家伙?非常感谢你! 此外,.h文件由xCode构成,只需控制从按钮拖动到.h并创建动作。这可能是原因吗?

1 个答案:

答案 0 :(得分:3)

我认为你不小心删除了这一行:

- (void)viewDidLoad

在这一行之上

{      **// Error is on this line[23]**

但为了简单起见,你可以删除它:

{      **// Error is on this line[23]**
     [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
 }

因为你没有使用viewDidLoad来做任何事情