Last active
October 26, 2017 10:18
-
-
Save soxjke/7a503195b59911eb8078cf6e584bc98a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import UIKit | |
| class WeatherView: UIView { | |
| private struct Const { | |
| static let cellIdentifier = "WeatherFeatureCell" | |
| } | |
| @IBOutlet private weak var tableView: UITableView! | |
| static func fromNib() -> WeatherView { | |
| guard let view = Bundle.main.loadNibNamed("WeatherView", owner: nil)?.first as? WeatherView else { | |
| fatalError("No bunlde for: \(String(describing: self))") | |
| } | |
| return view | |
| } | |
| override func awakeFromNib() { | |
| super.awakeFromNib() | |
| tableView.register(UINib.init(nibName: Const.cellIdentifier, bundle: nil), forCellReuseIdentifier: Const.cellIdentifier) | |
| } | |
| } | |
| extension WeatherView: UITableViewDelegate {} | |
| extension WeatherView: UITableViewDataSource { | |
| func numberOfSections(in tableView: UITableView) -> Int { | |
| return 1 | |
| } | |
| func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
| return 3 | |
| } | |
| func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
| return tableView.dequeueReusableCell(withIdentifier: Const.cellIdentifier, for: indexPath) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment