从块中解除模态视图时Dealloc不运行 [英] Dealloc Not Running When Dismissing Modal View from Block

查看:65
本文介绍了从块中解除模态视图时Dealloc不运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里奇怪的是,当从一个区块内被解雇时,dealloc没有被调用。代码:

Strange one here, dealloc is not being called when dismissed from inside a block. Code:

[[NSNotificationCenter defaultCenter] addObserverForName:@"user.login" object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notif) {

[self dismissModalViewControllerAnimated:YES];

 }];

任何人都知道为什么会这样?我如何从块中解除并同时运行dealloc?

Anyone know why this would be the case? How can i dismiss from inside the block and run dealloc at the same time?

我尝试过自动执行器,但这没有任何区别。

I have tried self performselector but this did not make any difference.

谢谢

推荐答案

我推荐你:块中自我引用的计数

该块将保留 self 直到块被释放。因此,对于dealloc self ,您需要删除观察者。

The block will retain self until the block is released. So to dealloc self, you'll need to remove the observer.

这篇关于从块中解除模态视图时Dealloc不运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆