Following
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?
- Class AC Implement ai{
- void print () {
- System.out.println (' Hello world ');
- }
- };
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