And*_*rew 0 iphone xcode uitableview tableview ios
所以我有一个UITableView,我用table中的数据填充tableview .plist.这对我来说一直很好,直到今天,当我试图做同样的事情,我无法得到numberOfRowsInSection,方法工作.这是我的代码:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if...
else if (segmentOptions == exchange){
NSArray *array = [NSArray arrayWithArray:[exchangeDictionary objectForKey:[listOfExchanges objectAtIndex:section]]];
return [array count];
}
//Else
return contentArray.count;
}
Run Code Online (Sandbox Code Playgroud)
因此,在该代码中,每次运行代码时,代码都会崩溃.但是,我使用基本相同的代码来设置tableview文本,并且工作正常:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}
if...
else if (segmentOptions == exchange) {
NSArray *array = [NSArray arrayWithArray:[exchangeDictionary objectForKey:[listOfExchanges objectAtIndex:indexPath.section]]];
cell.textLabel.text = [array objectAtIndex:indexPath.row];
}
return cell;
}
Run Code Online (Sandbox Code Playgroud)
并且该代码工作正常,这就是为什么我很困惑.当我设置返回到特定数字的行数,并运行其余代码时,一切正常.所以我真的迷路了.提前发酵
更新
我用正确的count符号尝试了return [array count];,我仍然得到相同的崩溃和相同的控制台输出.
首先,count不是属性,因此您不应该使用点语法来访问它.
我建议您更改代码,以便不像属性那样访问count方法.
第二,
测试你的数组是否为nil,它甚至是一个数组.
第三,
发布实际的完整堆栈跟踪.
| 归档时间: |
|
| 查看次数: |
2567 次 |
| 最近记录: |