Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/94.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UITableView索引XPath错误_Ios_Objective C_Uitableview - Fatal编程技术网

Ios UITableView索引XPath错误

Ios UITableView索引XPath错误,ios,objective-c,uitableview,Ios,Objective C,Uitableview,我使用UiTableView显示数据库中的一些数据。代码是 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath]; // Configure

我使用UiTableView显示数据库中的一些数据。代码是

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];

// Configure the cell...
NSInteger uniqueId = [self.database.arrayColumnNames indexOfObject:@"id"];
NSInteger title = [self.database.arrayColumnNames indexOfObject:@"title"];
NSInteger Name = [self.database.arrayColumnNames indexOfObject:@"Name"];
NSInteger picture = [self.database.arrayColumnNames indexOfObject:@"pictureName"];//3
cell.textLabel.text = [NSString stringWithFormat:@"%@: %@",[[self.arrayInfo objectAtIndex:indexPath.row] objectAtIndex:uniqueId], [[self.arrayInfo objectAtIndex:indexPath.row] objectAtIndex:title]];
cell.imageView.image = [UIImage imageNamed:[[self.arrayInfo objectAtIndex:indexPath.row] objectAtIndex:picture]];
cell.detailTextLabel.text = [NSString stringWithFormat:@"      %@", [[self.arrayInfo objectAtIndex:indexPath.row] objectAtIndex:bandName]];
return cell;
}

在我运行代码之后,我得到了一个错误

-[__NSArrayM objectAtIndex:]: index 3 beyond bounds [0 .. 2]

我在这个方法中添加了一些断点,看起来indexPath的长度是2,picture的NSInteger是3,所以发生了错误。这就是我对这个错误的想法,但我不知道如何解决它。

NSlog your self.arrayInfo。它应该只包含三个对象,而您正试图访问导致崩溃的第四个对象。您在
numberofrowsinssection
delegate中返回的行数是多少?@TejaNandamuri是的,我发现了问题。谢谢。@tx2我知道你的意思,但这不是问题所在。还是谢谢你。