devxoul / Then

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

lazy code #64

Closed hanks-hu closed 4 years ago

hanks-hu commented 5 years ago

lazy var tableView: UITableView = { let tabView =UITableView.init(frame: .zero, style: .plain) tabView.backgroundColor = UIColor.white tabView.dataSource = self tabView.delegate = self return tabView }() I often use lazy loading, and,how to write by Then。Can you give me a test code。

devxoul commented 5 years ago

Doesn't it work?

lazy var tableView = UITableView(frame: .zero, style: .plain).then {
  $0.backgroundColor = UIColor.white
  $0.dataSource = self
  $0.delegate = self
}
hanks-hu commented 5 years ago

😂,sorry,It's my problem。But, I found another problem。Code hinting。 Xcode Version 10.1 (10B61)。

2018-11-02 5 12 36 2018-11-02 5 13 26
SeRG1k17 commented 5 years ago

@devxoul Hi, sorry to bother you. Any updates about Carthage support?

iTofu commented 5 years ago

@HanksHu did your Xcode give you the hint now?

hanks-hu commented 5 years ago

@iTofu sorry. use let, give me hints.

let orderNumLabel = UILabel().then {
}

but,uselazy var, Don't give me hints.

 lazy var orderNumLabel = UILabel().then {
        $0.textColor = UIColor.init(hex: "b7b7b7")
        $0.numberOfLines = 1

    }
iTofu commented 5 years ago

@HanksHu fine and thank you :(

WannaYoung commented 5 years ago

@HanksHu me too use let, give me hints. uselazy var, Don't give me hints.