开发者

NSNotificationCenter: is it possible for it to listen in to other classes that do not explicitly post Notifications?

I am trying to listen for UIViewController methods being triggered (-viewDidLoad, -viewDidAppear, -viewDidUnload, -viewDidDisappear and so on) without modifying the actual code in the methods. Is this impossible? I'm trying to have an observer in another class listen in for those methods being called, but I don't开发者_Go百科 want to add postNotifications: to the View Controller. Do I have to?


No, it is not possible. You will have to add postNotifications: I'm afraid.


I'd subclass the UINavigationController to post the notifications you want. Alternatively I'd use swizzling with a category to add the notifications without touching the code of the class

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜