0

iPhone 開発と Objective-C は初めてなので、既に質問されていたらすみません。私はいくつかのコードに取り組んできましたが、何度もこのエラーがポップアップし続け、予想される識別子または '(' が 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
4

2 に答える 2

4

このメソッド定義でエラーが表示されている場合:

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

その理由は-、最初の(NSInteger).

すべての Objective-C メソッドの前には、メソッドが「インスタンス メソッド」であるか「クラス メソッド」であるかを示す-またはを付ける必要があります。+

于 2012-04-26T20:37:01.167 に答える
2

ダッシュと星が足りないようです。

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return tutorials.count;
} 
于 2012-04-26T20:36:47.930 に答える