【问题标题】:UIViewController do not call dealloc in ARC project?UIViewController 不在 ARC 项目中调用 dealloc?
【发布时间】:2012-05-17 06:18:25
【问题描述】:

在一个 ARC 项目中,我在 viewDidLoad:removeObserver:addObserverdealloc 中获取通知。但是在我弹出viewController之后,dealloc没有被执行。

- (void)viewDidLoad
{
    [super viewDidLoad];

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(refreshData)
                                                 name:MyNotification
                                               object:nil];
}

- (void)dealloc
{
    NSLog(@"==================");//There is nothing print out.
    [[NSNotificationCenter defaultCenter] removeObserver:self
                                                    name:MyNotification
                                                  object:nil];
}

谢谢。

【问题讨论】:

    标签: iphone objective-c automatic-ref-counting


    【解决方案1】:

    这可能是你启用了 nszobie 对象,禁用它们。我不知道为什么,但是如果在 arc 中启用了 nszombie,则不会调用 dealloc。

    转到产品>编辑方案>取消选中启用僵尸

    【讨论】:

    • 它工作!非常感谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-08-03
    • 1970-01-01
    • 2015-04-06
    • 1970-01-01
    • 2013-04-28
    • 2011-12-17
    • 1970-01-01
    相关资源
    最近更新 更多