Closed takasek closed 8 years ago
Hi @takasek!
Why do you need UILabel().then(tempt)
? As you mentioned, tempt(label1)
could be the solution.
In some case, I want to give then
a function, instead of a closure.
Consider of code to apply special animation to some buttons with a function below:
func applyInteractionAnimationToButton(button: UIButton) {
//long and complicated logic...
...
}
With Then 1.0.2
, I have to write:
let button = UIButton(frame: ...)
applyInteractionAnimationToButton(button)
self.contentView.addSubview(button)
or
self.contentView.addSubview(
UIButton(frame: ...).then {
applyInteractionAnimationToButton($0)
}
)
But I want to write:
self.contentView.addSubview(
UIButton(frame: ...).then(applyInteractionAnimationToButton)
)
It is comforting than former codes, isn't it?
@takasek, That's reasonable. I just released a new version 1.0.3 :smile:
Problem
The code below works in Then 1.0.1 but doesn't work in 1.0.2.
Adding
inout
keyword to the func resolves the error, but it brings another problem.To resolve all errors, I should write code as below.
I don't use neither
var
nor&
...Proposal
18 is nice-to-have modification, but old-style method(without
inout
keyword) is also nice in some situations.So why don't you implement another old-type method as
(@noescape block: Self -> Void) -> Self
?