-1

i dont know why the dealloc of the viewcontroller is not calling

please see the code snippet.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];

    SaleItemsVC *itemsObj = [[SaleItemsVC alloc] initWithNibName:@"SaleItemsVC" bundle:nil];
    [self.navigationController pushViewController:itemsObj animated:YES];

    EventSingleEntity *entityobj=(EventSingleEntity*)[arrSales objectAtIndex:indexPath.row];

    itemsObj.eveintEntityRef=entityobj;
    [itemsObj loadProductsOfEventId:entityobj.event_id];
    itemsObj.EventTitle.text=entityobj.name;
    itemsObj.EventEndDate.text=entityobj.end;
    SalesCell *cell=(SalesCell*)[tableView cellForRowAtIndexPath:indexPath];
    itemsObj.eventImage=cell.imgCenter.image;
    [itemsObj release];


}
Prabhat Kasera
  • 1,111
  • 11
  • 28
  • 1
    Pushing a view controller wouldn't cause the parent view controller to release or dealloc. Why are you expecting it to happen? – Michael Dautermann May 31 '12 at 15:52
  • 1
    Please tell us why you think `dealloc` should get called so we can fix the bug in your head. – tia May 31 '12 at 15:55

1 Answers1

1

You create itemsObj, the controller, so the ref count == 1

You push itemsObj to self.navigationController, refcount == 2

You release itemsObj ref count == 1

It should not be released until self.navigationController releases it.

Mark
  • 5,952
  • 3
  • 33
  • 49
  • my app contain 5 view controller all are properly deallocated but only have issue with this controller – Prabhat Kasera May 31 '12 at 15:56
  • If at some time the controller is supposed to be released, then check for retain cycles. Are the other controllers all of the same class (SaleItemsVC)? – Mark May 31 '12 at 16:24
  • actually the delegate of the network controller is of Retain type.. so it was a root cause. – Prabhat Kasera Jun 01 '12 at 06:45