如何使用 indexPath.row 从数组中获取对象?我已尝试使用以下代码,但它返回“信号 SIGABRT”.. 请帮助
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
NSString *inde = [NSString stringWithFormat:@"%d", indexPath.row];
NSNumber *num = [NSNumber numberWithInteger: [inde integerValue]];
int intrNum = [num intValue];
NSString *name = [basket objectAtIndex:intrNum];
cell.textLabel.text = name;
return cell;
}
- (void)viewDidLoad
{
[super viewDidLoad];
basket = [[NSMutableArray alloc] init];
[basket addObject:@"1"];
[self makeGrid];
}
- (void)addToBasket:(id)sender {
NSInteger prodID = ((UIControl*)sender).tag;
[basket insertObject:[NSNumber numberWithInt:prodID] atIndex:0];
[self.tableView reloadData];
}
错误信息:
-[__NSCFNumber isEqualToString:]: unrecognized selector sent to instance 0x6866080 2012-05-05 02:29:18.208 app[7634:f803] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber isEqualToString:]: unrecognized selector sent to instance 0x6866080'