In an ARC project, I addObserver for a notification in viewDidLoad: and removeObserver: in dealloc. But after I pop the viewController, dealloc is not executed.
- (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];
}
Thanks.
this may perhaps you have enabled nszobie objects, disable them. i don’t know why but if nszombie enabled in arc, dealloc is not invoked.
go to product>edit schems> unchek the enable zombie