0

I've checked my connections and class names as all the other threads with this same issue suggest.

Error message

*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key parksTableView.'

View controller where I get the crash

import UIKit

class ParksViewController: UITableView, UITableViewDataSource, UITableViewDelegate {

var parkNames = ["Sunnyside", "South Oak", "Tower", "Arno", "Arbor", "Holmes", "Brookside", "Brookside Tennis Courts", "Loose", "Gilham", "Brush Creek", "Westwood"]


@IBOutlet weak var textLabel: UILabel!
@IBOutlet weak var parksTableView: UITableView!

func viewDidLoad(){

self.parksTableView.delegate = self
self.parksTableView.dataSource = self


}

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

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = UITableViewCell()
    print(indexPath.row)

    cell.textLabel?.text = parkNames[indexPath.row]
    return cell
}

Maybe I'm just not connecting the right things to the right places? I've tried a combination of different connections and have deleted and reconnected connections many times in order to try to fix this issue, but it I still can't understand what is wrong.

Storyboard

Connection Inspector of ParksViewController

Alexander
  • 31
  • 8

1 Answers1

0

If you look at the error, it says <UIViewController 0x7fc416a04f80>. You think you have a ParksViewController but you really just have a plain UIViewController.

Lily Ballard
  • 182,031
  • 33
  • 381
  • 347
  • So what exactly needs to be changed in order for it to be a ParksViewController as it is named and everything? – Alexander Sep 08 '17 at 21:20