IN OBJECTIVEC EXTEND A @PROTOCOL IMPLEMENTATION

Pravesh Singh

Total Post:412

Points:2888
Posted by  Pravesh Singh
 641  View(s)
Ratings:
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.

  1. Tarun Kumar

    Post:214

    Points:1642
    Re: In objectiveC extend a @protocol implementation

    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
    }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!