I am currently programming a kind of analytics kit for some of my apps. Now I want to log every view which was on screen (e.g. every viewDidAppear: call UIViewController class). The most important thing is, that I do not want to change the code of my existing classes. So my question is, if开发者_如何转开发 there is a possibility to log each UIViewController which appeared on screen.
Thanks in advance.
Without having to change your existing code, you could use a category and method swizzling to do exactly what you want.
See here for more info: http://www.cocoadev.com/index.pl?MethodSwizzling
You could create a BaseViewController and inherit all your view controllers from this base controller. Inside the base controller's viewDidAppear, viewDidDisappear etc.. log what you want to.
精彩评论