我正在将购买的商品添加到数组中,这样我就可以轻松地检索数据并在表格视图中显示它们。但是我收到 sigabrt 错误。下面的代码有什么问题?
表视图
if (indexPath.section == 0) {
switch (indexPath.row) {
case 0:
cell.textLabel.text = @"Default Gun";
break;
case 1:
cell.textLabel.text = [[[[GameData sharedData] gunsArray] objectAtIndex:0] localizedTitle];
break;
default:
break;
}
- (NSMutableArray *) gunsArray {
SKProduct *product1 = [[InAppStore sharedStore] getGun1];
SKProduct *product2 = [[InAppStore sharedStore] getGun2];
SKProduct *product3 = [[InAppStore sharedStore] getGun3];
SKProduct *product4 = [[IInAppStore sharedStore] getGun4];
NSMutableArray *arr = [[NSMutableArray alloc] init];
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"isGun1Purchased"] == YES && ![arr containsObject:product1]) {
[arr addObject:product1]; // error occurs here
}
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"isGun2Purchased"] == YES && ![arr containsObject:product2]) {
[arr addObject:product2];
}
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"isGun3Purchased"] == YES && ![arr containsObject:product3]) {
[arr addObject:product3];
}
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"isGun4Purchased"] == YES && ![arr containsObject:product4]) {
[arr addObject:product4];
}
return [arr autorelease];
}