我无法解开我的 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 为我的生活。
任何帮助或调试提示将不胜感激......