每当您声明一个协议时,您还必须为其创建一个委托
id <AddContentViewControllerDelegate > delegateAddContent
并在 .m 文件中创建其属性 ans synthesize
@property (nonatomic) id delegateAddContent
米
@synthesize delegateAddContent
现在您必须通过您已经通过 .m 文件方法定义的协议方法发送数据。
[self delegateAddContent]AddContentViewControllerDidCancel:(AddContentViewController *)controller];
可能有一些你想发送数据的类。那个类必须符合你的协议,例如-->
@interface ClassName : SuperClass<AddContentViewControllerDelegate >
然后你必须实现协议的方法。/例如-->-
(void)AddContentViewControllerDidCancel:(AddContentViewController *)controller
{
//the data will be received in the parameters of the method of the protocol implemented.here in controller
}
符合协议的类也必须取得协议所有权
yourclassconformingprotocol.delegateController=self.
You can also define the required methods in protocol by @required and optional by @optional
See Apple's documentation on protocol