Home > DeveloperSection > Forums > In objectiveC extend a @protocol implementation
Pravesh Singh

Total Post:411

Points:2881
Posted on    November-25-2015 3:02 AM

 iPhone iPhone  Ios  Objective C 
Ratings:


 1 Reply(s)
 295  View(s)
Rate this:

I have created a class CountryListViewController which inherits from UIViewController.
I define an delegate 'CountryDelegate' in this class.

now, how can I inherit this delegate in another class and also can I extend the old webViewDidFininshLoad: method; because I want to execute some code after the webViewDidFinishLoad from the super class.



Tarun Kumar

Total Post:210

Points:1614
Posted on    December-14-2015 12:07 AM

To override webViewDidFinishLoad: method after implimenting the protocol and change or extend the behavior like this:
ViewController.h

ViewController : UIViewController {}
- (void)customWebViewDidFinishLoad:(UIWebView *)customWebView;

ViewController.m

- (void)webViewDidFinishLoad:(UIWebView *)webView {
    [self customWebViewDidFinishLoad:self.webView];
}

 

// Override this method in CustomViewController.m
- (void)customWebViewDidFinishLoad:(UIWebView *)webView {
    // Default behavior
}

CustomViewController.h

CustomViewContorller : ViewController

CustomViewController.m

- (void)customWebViewDidFinishLoad:(UIWebView *)webView {
  [super customWebViewDidFinishLoad:webView];
  //Extend the behaviour here
}

Don't want to miss updates? Please click the below button!

Follow MindStick