Created
May 9, 2019 14:22
-
-
Save e-sung/2e99e28923f8c95bdbb0a3363afb8bd3 to your computer and use it in GitHub Desktop.
This file contains 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
// 옛날 버전. "세그먼트 콘트롤이 눌리면 테이블뷰를 리로드하라"로 밖에 읽히지 않는다. | |
@IBAction func segementSelected(_ sender: UISegmentedControl) { | |
tableView.reloadData() | |
} | |
// 리팩토링버전. "선택된 세그먼트에 해당되는 데이터로 테이블을 채워라"라는 의도가 보인다. | |
@IBAction func segementSelected(_ sender: UISegmentedControl) { | |
tableView.dataSource = dataSources[sender.selectedSegmentIndex] | |
tableView.reloadData() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment