tags:

views:

29

answers:

1

Hi guys,

Here Im having a doubt that I am having an MasterViewController which doesnot have Superview and I am having labels which was declared globally and also used in different functions. My question is how can I release those labels which are allocated.if I use autorelease then it generating exceptions.

- (id)init {
   if(self = [super init]) {

mview = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
    //mview.backgroundColor=[UIColor clearColor];
    mview.autoresizesSubviews=YES;
    tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,220,320,440) style:UITableViewStyleGrouped];    
    tableView.delegate = self;
    tableView.dataSource = self;
    tableView.rowHeight = 45;
    tableView.backgroundColor = [UIColor clearColor];;
    tableView.separatorColor = [UIColor blackColor];
    [tableView setSectionHeaderHeight:15];
    [tableView setSectionFooterHeight:10];
[mview addSubview:tableView];
}
 for example here I declared table view as global how can i release it?Is it possible to release in dealloc.I place a printf statement in dealloc but it was not displaying.

Anyone's help will be appreciated.

Thank you,

Monish Kumar.
A: 

First off there is really no need to declare so many things globally, really it's something you should only use as a last resort. So I would try and redo your code to avoid that.

It sounds like for this you really need to run the Zombies instrument in Instruments and enable NSZombiesEnabled to YES for an environment variable and see where your objects retain count is being incremented & decremented and where the first instance of a zombie object being messaged is.

You can see an example of this here: http://www.corbinstreehouse.com/blog/2007/10/instruments-on-leopard-how-to-debug-those-random-crashes-in-your-cocoa-app/

Colin Wheeler