@interface, @implementation, @protocal in Objective-c

Source: Internet
Author: User

Following

    • void print ();
    • };
    • Class ac{
    • };
  • At this time, the AI and AC are independent, AC does not have to build a relationship with the AI to compile the error, the following modifications to the AC, the AI to establish a relationship with AC, AC must implement the method declared in the AI to compile.

    [HTML] view Plaincopyprint?
    1. Class AC Implement ai{
    2. void print () {
    3. System.out.println (' Hello world ');
    4. }
    5. };

    Now, let's see <foundation/foundation.h>
  • @protocol A
  • @end
  • <strong style="Color:white;background-color: #880000"> @interface</Strong > A:nsobject<A>
  • -(void) test: (ID<A>) obj;
  • @end

  • Notice here-(void) test: (id<a>) obj; This indicates that the test method accepts an arbitrary type of object as a parameter, but the parameter object must implement interface A, similar to the one in Java

    void Test (List<a> obj).

@interface, @implementation, @protocal in Objective-c

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.