我想送對象選擇在NSNotification.I的意思是,我有3個按鈕和每個按鈕的點擊我註冊的通知,並在該事件發生我打電話一個選擇,並在選擇我要找出哪個按鈕用戶點擊了,因爲我對所有3個按鈕都有共同的操作。如何在NSNotification中發送對象?
-(void)allThreeButtonAction:(sender)id
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(performSomeOperationWhenEventOccur) name:@"EventCompletedNotification" object:nil];
}
//一些事件發生,所以我送通知
[[NSNotificationCenter defaultCenter] postNotificationName:@"EventCompletedNotification" object:nil];
//通知的方法
-(void)performSomeOperationWhenEventOccur
{
//Here I want to know which button is pressed.
}
我希望我很清楚。
但如何我將在postNotificationName:object:userInfo中發送按鈕?我知道哪個按鈕只有當我註冊通知,在按鈕動作,即當我打電話時按下[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(performSomeOperationWhenEventOccur :) name:@「EventCompletedNotification 「object:nil] ;. –