Что не так для кода ниже:
// MARK: - TABLEVIEW DATA SOURCE
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
override func tableView(_ tableView: UITableView,
numberOfRowsInSection section: Int) -> Int {
return weeklyWeather.count
}
func tableView(tableView: UITableView, cellForRowAt indexPath:
IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell")
as! DailyWeatherTableViewCell
let dailyWeather = weeklyWeather[indexPath.row]
if let maxTemp = dailyWeather.maxTemperature {
cell.temperatureLabel.text = "\(maxTemp)"
}
cell.weatherIcon.image = dailyWeather.icon
cell.dayLabel.text = dailyWeather.day
return cell
}
Я пытался использовать протоколы UITableViewDataSource и UITableViewDelegate для объявления ViewController.
и моего DailyViewController:
class DailyViewController: UIViewController,
CLLocationManagerDelegate {
// MARK: properties
@IBOutlet weak var weatherIcon: UIImageView!
@IBOutlet weak var summaryLabel: UILabel!
@IBOutlet weak var sunriseTimeLabel: UILabel!
@IBOutlet weak var sunsetTimeLabel: UILabel!
@IBOutlet weak var lowTemperatureLabel: UILabel!
@IBOutlet weak var highTemperatureLabel: UILabel!
@IBOutlet weak var precipitationLabel: UILabel!
@IBOutlet weak var humidityLabel: UILabel!
и WeeklyTableViewController:
class WeeklyTableViewController: UITableViewController {
// MARK: - PROPERTIES
@IBOutlet weak var currentTemperatureLabel: UILabel?
@IBOutlet weak var currentWeatherIcon: UIImageView?
@IBOutlet weak var currentPrecipitationLabel: UILabel?
@IBOutlet weak var currentTemperatureRangeLabel: UILabel?
, но мне не удается получить ячейку из ее источника данных
Полное исключение:
Terminating app due to uncaught exception
'NSInternalInconsistencyException', reason: 'UITableView
(<UITableView: 0x7fcfa7038600; frame = (0 0; 414 896);
clipsToBounds = YES; autoresize = W+H; gestureRecognizers =
<NSArray: 0x600003a31800>; layer = <CALayer: 0x600003476ca0>;
contentOffset: {0, -88}; contentSize: {414, 684};
adjustedContentInset: {88, 0, 34, 0}>) failed to obtain a cell
from its dataSource (<Rainy.WeeklyTableViewController:
0x7fcfa800c200>)'