Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 如何在MasterViewController中释放对象_Objective C - Fatal编程技术网

Objective c 如何在MasterViewController中释放对象

Objective c 如何在MasterViewController中释放对象,objective-c,Objective C,这里我有一个疑问,我有一个MasterViewController,它没有Superview,我有一个全局声明的标签,也用于不同的功能。 我的问题是如何释放那些已分配的标签。如果我使用自动释放,则会生成异常 - (id)init { if(self = [super init]) { mview = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; //mview.background

这里我有一个疑问,我有一个MasterViewController,它没有Superview,我有一个全局声明的标签,也用于不同的功能。 我的问题是如何释放那些已分配的标签。如果我使用自动释放,则会生成异常

- (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.

首先,真的没有必要在全球范围内申报这么多东西,真的,这是你应该在万不得已的情况下才使用的东西。所以我会尝试重做你的代码来避免这种情况

听起来您确实需要在Instruments中运行Zombies工具,并为环境变量启用NSZombiesEnabled为YES,然后查看对象保留计数的递增和递减位置,以及发送消息的zombie对象的第一个实例的位置


你可以在这里看到这样一个例子:

嘿,伙计们,请帮我做这个。