import UIKit
class ViewController: UIViewController {
// delegate, datasource 설정
@IBOutlet weak var weaklyWeatherTableView: UITableView! {
didSet {
weaklyWeatherTableView.dataSource = self
weaklyWeatherTableView.delegate = self
}
}
let weatherData = ["16", "24", "17", "34", "16", "24", "17"]
override func viewDidLoad() {
super.viewDidLoad()
// xib 설정
weaklyWeatherTableView.register(UINib(nibName: "WeaklyWeatherTableViewCell", bundle: nil), forCellReuseIdentifier: "weatherTableViewCell")
}
}
extension ViewController: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
weatherData.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = weaklyWeatherTableView.dequeueReusableCell(withIdentifier: "weatherTableViewCell", for: indexPath) as! WeaklyWeatherTableViewCell
cell.maximumTeperatureLabel.text = weatherData[indexPath.row]
return cell
}
}