MAIN DIFFERENCE BETWEEN @OPTIONAL AND @REQUIRED KEYWORDS.

Tarun Kumar

Total Post:107

Points:535
Posted by  Tarun Kumar
 1053  View(s)
Ratings:
Rate this:
  1. Tarun Kumar

    Post:107

    Points:535
    Main difference between @Optional and @required keywords.

    Protocol methods can be marked as optional using the @optional keyword. Corresponding to the @optional modal keyword, there is a @required keyword to formally denote the semantics of the default behavior. You can use @optional and @required to partition your protocol into sections as you see fit. If you do not specify any keyword, the default is @required, or you can say that the @optional directive applies to any methods that follow it, either until the end of the protocol definition, or until another directive is encountered, such as @required.
    For example:

    @protocol MyProtocol
      @optional
      -(void) optional_method_name;
      @required
      -(void) required_method_name;
    @end

Answer

NEWSLETTER

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