The protocol in Objective-c, equivalent to the interface in Java
Reference: http://www.cnblogs.com/zzy0471/p/3894307.html
A simple protocol to follow:
PersonProtocol.h
@protocol Agreement name < superior Agreement name >
@required
Methods that must be implemented
@optional
Optional method of implementation (can not be implemented)
@end
Before you follow the agreement, you need to introduce a protocol-written header file
Person.h
Class name < protocol name > represents all methods that follow this protocol and need to implement the @required part of the protocol.
PERSON.M Implementation Section
Use of the protocol:
Protocoltest, customizing a protocol test class
ProtocolTest.h
Protocoltest.m
Main.m
The protocol for the Test class, which points to the Protocol already implemented in the person.
Output:
OBJECTIVE-C study notes-First day (2)