Last active
August 10, 2019 05:51
-
-
Save muizidn/137b954fd4e21a92821ece4091e17517 to your computer and use it in GitHub Desktop.
Make autocompletion gives you better result when assign closure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Eg: Closure<(Int) -> Void> | |
struct Closure<T> { | |
let closure: T | |
} | |
class LoginView: UIView { | |
var appereanceConfig: Closure<(UIStackView)->Void> = .init { _ in } | |
private stackView: UIStackView() | |
convenience init() { | |
self.init(frame: .zero) | |
appereanceConfig.closure(stackView) | |
} | |
} | |
let v = LoginView() | |
// Was | |
// Here we don't get good completion | |
v.appereanceConfig = { stack in | |
} | |
// But now its better | |
v.appereanceConfig = .init { stack in | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment