views:

39

answers:

0

HI,

I've a strange problem concerning dequeueReusableCellWithIdentifier dequeueing a custom cell. It said that I am sending a message to a deallocated instance to an object inside that function, but I have not deallocated or released the custom cell since its creation. What could be the problem? Does deleting a cell in the tableview release the cell inside the cache as well?

Offending code:

// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"TodaysOrderCell";
    static NSString *BlankIdentifier = @"BlankCell";

    UITableViewCell *cell;
    if ([outstandingOrdersArray count] == 0) {
        cell = [tableView dequeueReusableCellWithIdentifier:BlankIdentifier];
        if (cell == nil) {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:BlankIdentifier] autorelease];
            cell.accessoryType = UITableViewCellAccessoryNone;
        }

        [cell.textLabel setText:@"No Orders"];

    } else {
        cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            cell = [[[SingleOrderTableCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];

            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        }

        SingleOrder *order = [outstandingOrdersArray objectAtIndex:indexPath.row];
        [(SingleOrderTableCell *)cell setOrderData:order];
    }

    return cell;
}

Stacktrace:

#0  0x32d679a0 in ___forwarding___ ()
#1  0x32d5e840 in __forwarding_prep_0___ ()
#2  0x30c93ae0 in -[UITableView dequeueReusableCellWithIdentifier:] ()
#3  0x00030d6a in -[OutstandingOrdersDataSource tableView:cellForRowAtIndexPath:] (self=0x21df80, _cmd=0x319825a0, tableView=0x875400, indexPath=0x2c830a0) at /Users/chiyin/Xcode/AyersGTS/Classes/OutstandingOrdersDataSource.m:41
#4  0x30c93188 in -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:] ()
#5  0x30c92de0 in -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:] ()
#6  0x30c3e32c in -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow] ()
#7  0x30c3c514 in -[UITableView layoutSubviews] ()
#8  0x30c382d8 in -[UIView(CALayerDelegate) _layoutSublayersOfLayer:] ()
#9  0x33e871c0 in -[CALayer layoutSublayers] ()
#10 0x33e86edc in CALayerLayoutIfNeeded ()
#11 0x33e86844 in CA::Context::commit_transaction ()
#12 0x33e86474 in CA::Transaction::commit ()
#13 0x33ecd794 in CA::Transaction::release_thread ()
#14 0x32758e14 in _pthread_tsd_cleanup ()
#15 0x32758978 in _pthread_exit ()
#16 0x33f7cf02 in +[NSThread exit] ()
#17 0x33f2ad2a in __NSThread__main__ ()
#18 0x327587b8 in _pthread_body ()
#19 0x00000000 in ?? ()