1
我有一個視圖控制器乙其爲甲 .I亞類已經在A的viewWillAppear中註冊名爲kMyNotificaitonName通知這樣NSNotificationCenter從超類或子類調用方法?
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(MyNotificaitonNameHandler:) name: kMyNotificaitonName object:nil];
我已經實現MyNotificaitonNameHandler in view controller A and B哪種方法會得到ca大會另作?
我在我的問題中提到我在A的ViewWillAppear註冊。那麼會被稱爲?你的意思是哪個是不可預測的? – jailani 2014-10-28 10:10:13
@jailani我明白。我已經徹底閱讀了你的問題。我不說這取決於你在哪裏添加了你的對象作爲觀察者,我說它取決於你的對象是什麼類的類。你寫了「我有一個視圖控制器B」,這意味着B的實現將被稱爲 – 2014-10-28 10:11:44
@jailani它是100%可預測的。它只取決於對象的類型而沒有別的。這是多態性 – 2014-10-28 10:15:11