Skip to content

Instantly share code, notes, and snippets.

@soxjke
Last active October 26, 2017 10:18
Show Gist options
  • Select an option

  • Save soxjke/7a503195b59911eb8078cf6e584bc98a to your computer and use it in GitHub Desktop.

Select an option

Save soxjke/7a503195b59911eb8078cf6e584bc98a to your computer and use it in GitHub Desktop.
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