devxoul / Then

✨ Super sweet syntactic sugar for Swift initializers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

lazy code

hanks-hu opened this issue · comments

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。

Doesn't it work?

lazy var tableView = UITableView(frame: .zero, style: .plain).then {
  $0.backgroundColor = UIColor.white
  $0.dataSource = self
  $0.delegate = self
}

😂,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

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

commented

@HanksHu
did your Xcode give you the hint now?

@iTofu sorry.
use let, give me hints.

let orderNumLabel = UILabel().then {
}

but,use lazy var, Don't give me hints.

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

@HanksHu
fine and thank you :(

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