Note that there are some explanatory texts on larger screens.

plurals
  1. POUITableViewController crashes in tableView: cellForRowAtIndexPath:
    primarykey
    data
    text
    <p>I have a TableView in which I am adding custom UILabels to the UITableViewCells. The tableView loads fine, but when it tries to dequeue a cell after scrolling the app crashes when it tries to set the text of the UILables. Code follows:</p> <pre><code>#define STYLE_NUMBER_TAG 0 #define COLORWAY_TAG 1 #define SIZE_TAG 2 #define QUANTITY_TAG 3 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { // Get the managedObject NSManagedObject *managedObject = [fetchedResultsController objectAtIndexPath:indexPath]; OrderLineItem *item = (OrderLineItem *)managedObject; static NSString *CellIdentifier = @"lineItemCell"; UILabel *styleNumberLabel, *colorwayLabel, *sizeLabel, *quantityLabel; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; quantityLabel = [[[UILabel alloc] initWithFrame:CGRectMake(5, 5, 70, 20)] autorelease]; quantityLabel.tag = QUANTITY_TAG; [cell.contentView addSubview:quantityLabel]; styleNumberLabel = [[[UILabel alloc] initWithFrame:CGRectMake(85, 5, 70, 20)] autorelease]; styleNumberLabel.tag = STYLE_NUMBER_TAG; [cell.contentView addSubview:styleNumberLabel]; colorwayLabel = [[[UILabel alloc] initWithFrame:CGRectMake(165, 5, 70, 20)] autorelease]; colorwayLabel.tag = COLORWAY_TAG; [cell.contentView addSubview:colorwayLabel]; sizeLabel = [[[UILabel alloc] initWithFrame:CGRectMake(245, 5, 70, 20)] autorelease]; sizeLabel.tag = SIZE_TAG; [cell.contentView addSubview:sizeLabel]; } else { styleNumberLabel = (UILabel *)[cell.contentView viewWithTag:STYLE_NUMBER_TAG]; colorwayLabel = (UILabel *)[cell.contentView viewWithTag:COLORWAY_TAG]; sizeLabel = (UILabel *)[cell.contentView viewWithTag:SIZE_TAG]; quantityLabel = (UILabel *)[cell.contentView viewWithTag:QUANTITY_TAG]; } // Configure the cell... styleNumberLabel.text = item.style.styleNumber; //CRASHES HERE when dequeueing colorwayLabel.text = item.colorway; sizeLabel.text = item.size; quantityLabel.text = [item.quantity stringValue]; return cell; </code></pre> <p>}</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload