devxoul / Then

✨ Super sweet syntactic sugar for Swift initializers
MIT License
4.18k stars 290 forks source link

How to set delegate or add target in closure? #41

Closed wenzhaot closed 7 years ago

wenzhaot commented 7 years ago
lazy var recordButton = UIButton().then {
        $0.setTitle("Start", forState: .Normal)
        $0.setTitle("Stop", forState: .Selected)
        $0.addTarget(self, action: #selector(someAction), forControlEvents: .TouchUpInside)
    }

The "self" cannot be used.

wenzhaot commented 7 years ago

30 fixed