发布
社区首页 >问答首页 >索引开发工具:返回‘iOS 1 out out bound’的UITableView标签的NSArray

索引开发工具:返回‘iOS 1 out out bound’的UITableView标签的NSArray
EN

Stack Overflow用户
提问于 2013-04-10 07:59:18
回答 1查看 298关注 0票数 0

Gday,试图将我的循环tableview数组拆分为它自己的静态数组,然后在UITableView中的每个标签上使用该数组…

代码语言:javascript
代码运行次数:0
复制
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"ListingCell";

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

//Load Row Value into NSArray
NSString *RowValues = [self.ListingArray objectAtIndex:[indexPath row]];
NSArray *RunTimeArray = [RowValues componentsSeparatedByString:@","];


//Configure the cell.
cell.detailTextLabel.text = [RunTimeArray objectAtIndex:1]; //small label
cell.textLabel.text = [RunTimeArray objectAtIndex:0]; //main title

return cell;
}

当我运行项目时,它返回一个错误:

代码语言:javascript
代码运行次数:0
复制
DATE APP_NAME[28399:c07] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 1 beyond bounds [0 .. 0]'

基本上,这意味着Index :1不存在,但Index:0确实存在...例如,当我使用‘-’重新连接数组时,它都显示正确,这意味着新对象的索引不同于1或另一个连续的数字。

是否知道如何使它们连续索引,如: 0,1,2,3,4,而不是0,21581,2185929,385749……

谢谢:)

EN

回答 1

Stack Overflow用户

发布于 2013-04-10 11:09:20

验证以下内容

1) numberOfRowsInSection中返回值:应为self.listingArray count;

2) RunTimeArray计数应始终为>=2。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15914626

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档