1

我无法解开我的 NSRangeException 之谜。

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


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

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"Inside masterview cellforrowatindexpath.\n");

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }

    // Configure the cell...
    cell.textLabel.text = [_countyList objectAtIndex:indexPath.row];

    return cell;
}

当我numberOfSectionsInTableView返回 1(应该有 1 个部分)时抛出异常,但是当我返回 0 个部分时它不会抛出异常(它也不会显示我的数据)。当代码运行时,它从不调用cellForRowAtIndexPath. 调试器将我带到主要功能,我无法看到我在哪里访问 NSArray 为我的生活。
任何帮助或调试提示将不胜感激......

4

1 回答 1

2

如果您使用情节提要,请查看此帖子。

iOS Xcode 4.2 主从应用程序模板抛出 NSRangeException

您描述的问题看起来与那个相似。

于 2011-12-13T04:59:00.190 回答