我加入這個代碼在viewDidLoad中檢測鍵盤的顯示/隱藏:刪除NSNotificationCenter觀察者
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardDidHide:)
name:UIKeyboardDidHideNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification
object:nil];
在某些時候,雖然我想刪除這些觀察員,而不調用
[[NSNotificationCenter defaultCenter] removeObserver:self];
,因爲這會刪除所有觀察者,並且我有其他觀察員不希望被刪除。我怎樣才能刪除這兩個?