12
我要麼大腦受損或我缺乏NSNotificationCenterNSNotification removeObserver問題
的一些understending的問題是,如果我創建一個觀察者,並在下一行會嘗試刪除它,像這樣:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(removeAllVisibleMapViews) name:@"ClearVisibleMaps" object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self forKeyPath:@"ClearVisibleMaps"];
我得到
*** Terminating app due to uncaught exception 'NSRangeException', reason: 'Cannot remove an observer <MyApp 0x592db70> for the key path "ClearVisibleMaps" from <NSNotificationCenter 0x4e0fbb0> because it is not registered as an observer.'
我添加和刪除觀察者線線後僅提出一個觀點。在我的代碼中,我將在dealloc中使用remove。
因此,任何想法,爲什麼它不告訴我,我並沒有在第一時間添加和觀察員?
謝謝,所以這是真的我腦損壞:-)嘿嘿,至少今天。 – Cyprian 2011-05-11 09:24:51