2012-04-26 32 views
0

我是iPhone開發和Objective-C的新手,所以如果已經有人問我這個問題,我一直在研究一些代碼,並且一次又一次地出現這個錯誤彈出告訴我預期的標識符或「(」預期之前NSInteger的。預期的標識符或'('在NSInteger之前

#import "tableTutViewController.h" 


@implementation tableTutViewController; 

(NSInteger)tableView:(UITableView)tableView numberOfRowsInSection:(NSInteger)section{ 
    return tutorials.count; 
} 

- (void)viewDidLoad { 
    NSString * theFile = [[NSBundle mainBundle] 
          pathForResource:@"TPL" ofType:@"plist"]; 
    tutorials = [[NSArray alloc] initWithContentsOfFile:theFile]; 
    [super viewDidLoad]; 
} 

- (void)didReceiveMemoryWarning { 
    // Releases the view if it doesn't have a superview. 
    [super didReceiveMemoryWarning]; 

    // Release any cached data, images, etc that aren't in use. 
} 

- (void)viewDidUnload { 
    // Release any retained subviews of the main view. 
    // e.g. self.myOutlet = nil; 
} 

- (void)dealloc { 
    [super dealloc]; 
} 

@end 

回答

2

看起來你只是缺少一個破折號和一個明星。

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ 
    return tutorials.count; 
} 
+0

它給了我另一個錯誤,告訴我我不能使用一個對象作爲方法的參數。 – user1359673 2012-04-26 20:38:45

+0

不要緊,謝謝你的快速回復傢伙,非常感謝,解決了。 – user1359673 2012-04-26 20:40:06

+1

將答案標記爲正確答案 – Mario 2012-04-26 20:48:34

4

如果你指的錯誤顯示對於此方法定義:

(NSInteger)tableView:(UITableView)tableView numberOfRowsInSection:(NSInteger)section 
{ 
    return tutorials.count; 
} 

那麼原因是你在第一個(NSInteger)之前丟失了-

所有Objective-C方法都需要在-+之後,分別指示該方法是「實例方法」還是「類方法」。

相關問題