您的位置:首页 > 其它

实现代理相关的“标准”格式

2016-05-17 19:24 246 查看
import UIKit

class ViewController: UIViewController {

@IBOutlet
weak var closureLabel:
UILabel!

@IBOutlet
weak var label:
UILabel!

override
func viewDidLoad() {

super.viewDidLoad()

// Do any additional setup after loading the view, typically from a nib.

}

override
func didReceiveMemoryWarning() {

super.didReceiveMemoryWarning()

// Dispose of any resources that can be recreated.

}

func closure(string:String) {

closureLabel.text = string

}

override
func prepareForSegue(segue:
UIStoryboardSegue, sender:
AnyObject?) {

if segue.identifier ==
"xxx" {

let vc = segue.destinationViewController
as! SecondViewController

vc.delegate =
self

}

}

}

extension ViewController:
SecondViewControllerDelegate {

func SecondViewControllerDelegate(source:[Int]) {

let string = source[0]

label.text =
String(string)

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: