2012-04-25 34 views
6

我有很多的UIViews進入人們的視野,然後走出去的觀點和不被使用。不過,我相信其中一些人在收到通知後仍會收到通知,即使這些通知消失後也會造成問題。IOS通知「死」的對象

在UIView的「父」容器:

if(self._content != nil && [self._content respondsToSelector:@selector(presentMe:)]) { 
    [self._content presentMe:NO]; 
} 

在UIView的「孩子」:

[[NSNotificationCenter defaultCenter] <-- EXC_BAD_ACCESS (code=1, address=0x70000008 
postNotificationName:PRESENTING 
object:self 
userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:prepareToEnter], PRESENTING, nil]]; 

一切工作第一次,但如果我啓動了同樣的看法第二次我得到一個EXC_BAD_ACCESS。這不是說有什麼缺失嗎?

FYI這是所有在ARC - Xcode的4.3.2

回答

12

如果您在您的視圖中的項目叫addObserver,你需要的dealloc期間調用removeObserver。即使使用ARC。