关于UITable视图的例外情况

时间:2013-04-06 09:01:17

标签: ios objective-c xcode4.3 uistoryboard

我是Objective C和iOS的新手。我已将View Controller上的导航控制器嵌入到故事板中。然后我在故事板中添加了另一个视图控制器,它是根视图控制器。它有一个连接到另一个视图控制器的按钮,该视图控制器添加了一个表视图。当我运行构建时,我得到以下异常:'NSInvalidArgumentException'原因:' - [UIViewController tableView:numberOfRowsInSection:]:无法识别的选择器发送到实例0x686d160'。这是实现文件中的代码(只有关联方法)请告诉我是否需要提供更多代码:

     (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
   {
    return [contacts count];
   }


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

    UITableViewCell *cell = [tableView   dequeueReusableCellWithIdentifier:simpleTableIdentifier];

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

    cell.textLabel.text = [contacts objectAtIndex:indexPath.row];
    return cell;
}

1 个答案:

答案 0 :(得分:0)

您正在向已取消分配的联系人变量发送“计数”消息。将对象分配给联系人时,请确保它通过在其上发送保留消息来拥有它,或者如果已启用它,则使用ARC等效项。