๊ธฐ๋ฅ ์ค๋ช
UIViewController์ ๊ธฐ๋ณธ ์ค์ ์ฝ๋๋ฅผ Protocol์ ์ด์ฉํด ์ ๋ฆฌ & ์ฝ๋ฉ ์ปจ๋ฒค์
์ ์ค์ํ๋๋ก ํ๋ค
ํ์ฌ ๋์
UIViewController ์ฝ๋์์ ์ด๊ธฐ ์ค์ ์ฝ๋๋ค์ ํ์ฌ๋ configureUI()์ constraint ์ค์ ์ฝ๋๋ฅผ ๋ฃ๊ณ viewDidLoad()์ ์ด๊ธฐ ์ค์ ์ฝ๋(.backgroundColor, tableView.delegate = self ๋ฑ)์ ๊ฐ์ด ๋ฃ๋ ๋ฐฉ์
๊ธฐ๋ ๋์
setUpView(), configureUI() ํจ์๋ฅผ ๊ฐ์ง๋ ํ๋กํ ์ฝ์ ๋ชจ๋ UIViewController์์ ์ฑํํ๊ฒ ํ๋ค
protocol WViewController {
func setUpView()
func configureUI()
func bindViewModel()
}
setUpView() - tableView.delegate = self ๊ฐ์ ๋ทฐ์ปจํธ๋กค๋ฌ ์์ฒด์ ๊ดํ ์ค์
configureUI() - addSubView()์ makeConstraints()3.
bindViewModel() - ๋ฐ์ดํฐ ๋ฐ์ธ๋ฉ
setUpView ํจ์๋ช
์ ์์์
๋๋ค
configureUI ํจ์๋ช
์ ํ์ฌ๋ ์ฌ์ฉ์ค์ด๋ฏ๋ก ๊ทธ๋๋ก ์ฌ์ฉํฉ๋๋ค