美文网首页iOS Development
swift ----- 代理用法

swift ----- 代理用法

作者: 71150ce14a00 | 来源:发表于2016-11-25 14:47 被阅读23次

发送代理页面

1. 声明代理方法

// 代理1

protocol getdataDelegate:NSObjectProtocol {

func getdata()

}

2. 在class中 声明代理属性

var deletage:getdataDelegate?

3. 在发送代理方法中

if (deletage != nil) {

deletage?.getdata()

}

在接受实现代理方法页面

1. 签代理

xxx.deletage = self

2. 实现代理方法

func getdata() {

}

相关文章

网友评论

    本文标题:swift ----- 代理用法

    本文链接:https://www.haomeiwen.com/subject/iptwpttx.html