Table view cell issues

I am have been trying to solve this issue all day, but I just can't seem to find the problem. My code is not showing any errors, which in this case it might have been easier. The issue is that I can't get my custom table view cell to show when simulating the app. I have gone through this process before and there have never been this kind of problem. Outside of my view controller I have a table view controller and a table view cell controller (to customize the cell). I have linked the table view controller with my table view controller storyboard, and I have given the table cell an identifier. I also have another file (Forecast.swift) dedicated to parse the JSON.


Any idea of what I am doing wrong?


Below is my code from table view controller:

import UIKit
import Alamofire
import CoreLocation
class ForecastTableViewController: UITableViewController, CLLocationManagerDelegate {

    let locationManager = CLLocationManager()
    var currentLocation: CLLocation!


    var forecast: Forecast!
    var forecasts = [Forecast]()


    func downloadForecastData(completed: DownloadComplete) {
        Alamofire.request(FORECAST_URL, withMethod: .get, parameters: nil, encoding: .json).responseJSON { response in
            let result = response.result
         
            if let dict = result.value as? Dictionary<String, AnyObject> {
             
                if let list = dict["list"] as? [Dictionary<String, AnyObject>] {
                 
                    for obj in list {
                        let forecast = Forecast(weatherDict: obj)
                        self.forecasts.append(forecast)
                        print(obj)
                    }
                    self.forecasts.remove(at: 0)
                    self.tableView.reloadData()
                }
            }
         
            completed()
        }
    }
    override func viewDidLoad() {
        super.viewDidLoad()
     
        tableView.delegate = self
        tableView.dataSource = self
        self.tableView.register(ForecastCell.self, forCellReuseIdentifier: "forecastCell")
     
    }
  
    override func viewDidAppear(_ animated: Bool) {
        locationAuthStatus()
    }

    func locationAuthStatus() {
        if CLLocationManager.authorizationStatus() == .authorizedWhenInUse {
            currentLocation = locationManager.location
            Location.sharedInstance.latitude = currentLocation.coordinate.latitude
            Location.sharedInstance.longitude = currentLocation.coordinate.longitude
            self.downloadForecastData(completed: {})
         
        } else {
            locationManager.requestWhenInUseAuthorization()
            locationAuthStatus()
        }
    }

    override func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }

    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return forecasts.count
    }


    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
     
     
        if let cell = tableView.dequeueReusableCell(withIdentifier: "forecastCell", for: indexPath) as? ForecastCell {
         
            let forecast = forecasts[indexPath.row]
            cell.configureCell(forecast: forecast)
            return cell
        } else {
            return ForecastCell()
        }
}
}


And here is my code for the custom table cell:

import UIKit
class ForecastCell: UITableViewCell {
    /
    @IBOutlet weak var weatherTypeImage: UIImageView!
    @IBOutlet weak var currentTempLabel: UILabel!
    @IBOutlet weak var maxTempLabel: UILabel!
    @IBOutlet weak var minTempLabel: UILabel!
    @IBOutlet weak var weekdayLabel: UILabel!
    @IBOutlet weak var weatherTypeLabel: UILabel!
  
  
  
    func configureCell(forecast: Forecast) {
  
        minTempLabel.text = "\(forecast.minTemp)"
        maxTempLabel.text = "\(forecast.maxTemp)"
        currentTempLabel.text = "\(forecast.forecastTemp)"
        weatherTypeLabel.text = forecast.weatherType
        weekdayLabel.text = forecast.date
        weatherTypeImage.image = UIImage(named: forecast.weatherType)
      
  
    }
}
Accepted Answer

Well, you never removed this line:


self.tableView.register(ForecastCell.self, forCellReuseIdentifier: "forecastCell")


That breaks your ForecastCell setup, because it causes the table view to create the cells via the designated init, which ignores the outlets and subviews you've configured in the storyboard. Without that line, it creates the ForecastCells via the NIB loading process instead, and I get a forecast table view full of forecasts.


(Well, in the last commit you'd commented out the forecast download, so there weren't any rows in the table. Luckily it was easy to put back the call to the download.)


(Also, you've got an infinite recursion crash if the user doesn't accept the use of location services.)

YOU ARE THE MAN! I feel quite stupid at the moment, but the only thing I want to do is to thank you over and over again!


See you on the Apple event stream tmr?


Many thanks,

Ceonn

Table view cell issues
 
 
Q