实现代理相关的“标准”格式
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)
}
}
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)
}
}
相关文章推荐
- 机器学习中为什么需要对数据进行归一化?
- hiho一下 第九十八周 题目1 : 搜索一·24点
- android代码中设置EditText的hint字体大小而不改变EditText的文字大小
- 专访阿里陈康贤:我所理解的网站架构
- Windows 回调监控 <一>
- java之将101-300范围内整数分解为质因数
- 微信公众号第三方平台开发PYTHON教程 PART 7
- [团队项目]SCRUM项目4.0
- 界面日期的比较
- nginx添加nginx_upstream_check_modules
- 设计模式之单例模式
- 2015年中国1%人口抽样调查主要数据公报(全文)
- Linux驱动开发要点
- ROS第一个程序:机器人直行和旋转
- Java字符串方法replace()、replaceAll()、replaceFirst()的区别和使用方法
- scala开发环境与编辑器
- UI
- 沉浸式标题栏样式
- httpclient 访问https
- Windows10系统下LAMP开发环境的搭建