Delegate pattern
delegation pattern
protocol ClassDelegate: class{
func b1Pressed()
}
class Class: UIView
{
weak var delegate: ClassDelegate?
...
func b1action(sender:UIButton)
{
self.delegate?. b1Pressed()
}
class ViewController: UIViewController, ClassDelegate {
override func viewDidLoad() {
super.viewDidLoad()
let class = Class(frame: CGRectMake(0, 0, 234, 234))
menu.delegate = self
...
}
...
func b1Pressed() {
println("clc")
}
...