Custom UITableViewCell loaded from StoryBoard not getting dealloc'ed

| | August 18, 2015

Here’s my code:

__weak CurrentViewController *weakSelf = self;
if (indexPath.row == 0) //Name Cell
{
    static NSString *CellIdentifier = @"NameCell";
    NameCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    __weak NameCell *weakCell = cell;
    cell.NameDidChangeBlock = ^(){
        weakSelf.zoneName = weakCell.NameTextField.text;
    };

    return cell;
}
else if (indexPath.row == 1) //Number Cell
{
    static NSString *CellIdentifier = @"NumberCell";        
    NumberCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    cell.someBlock = ^(){
        [weakSelf.navigationController popViewControllerAnimated:YES];
    };

    return cell;
}

Neither “NameCell” nor “NumberCell” dealloc method is getting called.
I have both these custom cells designed and put up as top level objects in CurrentViewController’s storyboard.

CurrentViewController’s dealloc is getting called, but custom cell’s dealloc’s aren’t.
I see in the Instruments that the retainCount of the custom cells increases each time creating an instance of CurrentViewController.

Here are my headers of Custom cells:

//NameCell.h:
@property(nonatomic, weak)IBOutlet UITextField *NameTextField;
@property (nonatomic, copy)NameDidChange NameDidChangeBlock;

//NumberCell.h
@property(nonatomic, weak)Manager *manager;
@property(nonatomic, weak)IBOutlet AKPickerView *pickerView;
@property(nonatomic, strong)NSArray *numbersArray;
@property(nonatomic)int selectedZoneNumber;
@property (weak, nonatomic) IBOutlet UIView *selectionBoxView;
@property (nonatomic, copy)some someBlock;

Any help here would be appreciated.
Thanks!

EDIT:
My tableView itself is not getting dealloc’ed after CurrentViewController gets dealloc’ed.
Tried to log through a UITableView category.
Still, guessing, why would my tableView wont get released when my viewController is already released. Seems too weird.

One Response to “Custom UITableViewCell loaded from StoryBoard not getting dealloc'ed”

  1. The Culprit was this Guy: ShowKit

    We had ShowKit Integrated into our App for Remote Support.

    Removing their SDK from our App did solve the above mentioned dealloc Issue (Not just the above, but there were more issues than we thought).

    I think ShowKit SDK does takes a copy of our App’s views and doesn’t return it back and may be the retain count of the copied views doesn’t goes to 0 at all.

    OR

    May be the SDK has an handle over my App’s UIWindow and they aren’t releasing it when not needed.

    That’s purely my guess, not sure though. They’ll have to answer it.

    I hope someone finds this helpful.

Leave a Reply to iOS_Developer