1

I'm trying to implement IAP in my app. Because I'm new to this I followed this tutorial: (http://www.raywenderlich.com/21081/introduction-to-in-app-purchases-in-ios-6-tutorial).

I get errors in this part of code:

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

SKProduct * product = (SKProduct *) _products[indexPath.row];
cell.textLabel.text = product.localizedTitle;

return cell;
}

First Error:

reason: 'unable to dequeue a cell with identifier Cell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard' -> I kicked out forIndexPath:indexPath.

Then I just only get this (useless) error:

Thread 1: EXC_BAD_ACCESS (code=1,address=0xb79a91cf)

My question is, has something been changed in iOS 8?

PS: Something to add by myself: I haven´t had ARC activated, that solved the other issues.

Tristan G
  • 1,720
  • 2
  • 13
  • 22

2 Answers2

2

In iOS 8 (or maybe even 7), the default behavior is that you'd use the prototype table cell with the name of "Cell". The problem appears that you don't have a prototype cell, so the cell is nil.

You can either get a prototype table cell defined, or you can explicitly create the cell like this:

UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"Cell"];
if (cell == nil) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"Cell"];

}
Mike M
  • 4,358
  • 1
  • 28
  • 48
1

Simply try this:

SKProduct *product = (SKProduct *)[_products objectAtIndex:indexPath.row];
cyberlobe
  • 1,783
  • 1
  • 18
  • 30