Uitableview 为SimpleTable练习引发异常错误

Uitableview 为SimpleTable练习引发异常错误,uitableview,Uitableview,我收到有关发送到选择器的错误消息的错误消息,但无法找到它: 2014-05-15 09:13:41.064 SimpleTable[4364:60b] The tableData array contains ( "Item 0", "Item 1", "Item 2", "Item 3", "Item 4", "Item 5", "Item 6", "Item 7", "Item 8", "Item 9" ) 20

我收到有关发送到选择器的错误消息的错误消息,但无法找到它:

2014-05-15 09:13:41.064 SimpleTable[4364:60b] The tableData array contains (
    "Item 0",
    "Item 1",
    "Item 2",
    "Item 3",
    "Item 4",
    "Item 5",
    "Item 6",
    "Item 7",
    "Item 8",
    "Item 9"
)
2014-05-15 09:13:41.101 SimpleTable[4364:60b] -[UIView tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x8fb1290
2014-05-15 09:13:41.113 SimpleTable[4364:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x8fb1290'
以下是.h文件:

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController <UITableViewDelegate, UITableViewDelegate>

@property (nonatomic, strong) NSMutableArray *tableData; // holds the table data
@property (nonatomic) int cellCount;

@end
#导入
@界面ViewController:UIViewController
@属性(非原子,强)NSMutableArray*tableData;//保存表数据
@属性(非原子)int-cellCount;
@结束
以下是.m文件:

 #import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

@synthesize tableData;

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    // Create the array to hold the table data
    self.tableData = [[NSMutableArray alloc] init];

    // Create and add 10 data items to the table data array
    for (NSUInteger i = 0; i < 10; i++) {

        // The cell will contain a string "Item X"
        NSString *dataString = [NSString stringWithFormat:@"Item %d", i];

        // Here the new string is added to the end of the array
        [self.tableData addObject:dataString];
    }
    // Print out the contents of the array into the log
    NSLog(@"The tableData array contains %@", self.tableData);
}

-(void)viewDidUnload
{
    [super viewDidUnload];
    self.tableData = nil;
}


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

#pragma mark - UITableViewDataSource

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [self.tableData count];
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];

    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];

        cell.textLabel.text = [self.tableData objectAtIndex:indexPath.row];


    }
    return cell;
}

@end
#导入“ViewController.h”
@界面视图控制器()
@结束
@实现视图控制器
@综合表格数据;
-(无效)viewDidLoad
{
[超级视图下载];
//加载视图后,通常从nib执行任何其他设置。
//创建数组以保存表数据
self.tableData=[[NSMutableArray alloc]init];
//创建10个数据项并将其添加到表数据数组中
对于(整数i=0;i<10;i++){
//单元格将包含字符串“Item X”
NSString*dataString=[NSString stringWithFormat:@“项%d”,i];
//这里,新字符串被添加到数组的末尾
[self.tableData addObject:dataString];
}
//将数组的内容打印到日志中
NSLog(@“tableData数组包含%@”,self.tableData);
}
-(无效)视图卸载
{
[超级视频下载];
self.tableData=nil;
}
-(无效)未收到记忆警告
{
[超级记忆警告];
//处置所有可以重新创建的资源。
}
#pragma标记-UITableViewDataSource
-(NSInteger)表格视图中的节数:(UITableView*)表格视图
{
返回1;
}
-(NSInteger)表视图:(UITableView*)表视图行数节:(NSInteger)节
{
返回[self.tableData count];
}
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
静态NSString*cellIdentifier=@“Cell”;
UITableViewCell*单元格=[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
如果(单元格==nil){
cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault重用标识符:cellIdentifier];
cell.textlab.text=[self.tableData对象索引:indexath.row];
}
返回单元;
}
@结束

可能xib/情节提要中UITableView的委托和数据源连接到视图而不是视图控制器。顺便说一句,这不是问题的原因,但在.h文件中有
——其中一个应该是
UITableViewDataSource
。这正是问题所在。谢谢你的帮助!