indexPath.row を使用して配列からオブジェクトを取得するにはどうすればよいですか? 次のコードを試してみましたが、「signal 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'