Modify behaviour of viewDidAppear in UIViewController
I have application (UICatalog from Apple samples). I am using it with a framework called Lookback which is intended for screen recording.
I have interface defined as follows:
@interface AAPLSteppperViewController : UITableViewController
So it is in a straight way a subclass of UITableViewController. And it has implemented a methods as follows:
+ (NSString*)lookbackIdentifier {
return @"Profile Editor";
}
I wanted to investigate how lookbackIdentifier is being called and see something like that:
The question is: how to introduce such behavior as UITableViewController is a system class and I am not able to see the source of calls numbered 1 and 2 at the stack?
As I investigated framework docs, they recommend to implement always like that
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
...
}
As for me it looks like a change inside UIViewController - but how to achieve something like that?
I guess that it will include some playing with UIViewController but - how? I can't imagine how to override a single method of it without subclasssing.
I have only access to my AAPLSteppperViewController.
I would be grateful if somebody could give me a push in the right direction
As @dan pointed - swizzling is the right answer. I tried with instructions there: http://nshipster.com/method-swizzling/ and it gave me desired behaviour.
Thanks for help :)
链接地址: http://www.djcxy.com/p/58362.html