1

So, this is a multi page application and whenever I switch to the page with the UITable present in it I face this error " setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key tableView." I got the same error before cause I forgot to add the numberOfRowsInSection function but even after adding that still I am facing the same error.

class workingQuery: UIViewController, UITableViewDelegate, UITableViewDataSource{


  @IBOutlet weak var tableViews: UITableView!


  override func viewDidLoad() {
    super.viewDidLoad()
  }

  override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated   
  }


  //TableView Code
  var names = ["Mark", "Cloyd", "Buck", "Steve", "Wallace"]
  var breeds = ["Labrador Retriver", "Bulldog", "German Shepherd", "Golden Retriver", "Yorkshire"]
  var images = [UIImage(named:"johnny"), UIImage(named:"dusra"), UIImage(named:"Third"), UIImage(named:"Fourth"), UIImage(named:"Fifth")]

  func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return 5

  }

  func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell = self.tableViews.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! CustomCell

    cell.photo.image = images[indexPath.row]
    cell.fullName.text = names[indexPath.row]
    cell.ageSex.text = breeds[indexPath.row]
    return cell

  }
}
vadian
  • 274,689
  • 30
  • 353
  • 361
  • 2
    check your outlets in storyboard... is there any unwanted outlet .. if yes than remove it – Bhavin Bhadani Apr 19 '16 at 07:27
  • Do your custom cell have external xib? If yes then u must register that xib in your tableview before use `dequeueReusableCellWithIdentifier ` – Tj3n Apr 19 '16 at 07:32

2 Answers2

6

Open your Storyboard (or Xib) and click on "File's Owner".

Select: View -> Utilities -> Show connections inspector

You'll see one connection with exclamation mark:

enter image description here

Click on X to remove this connection, build & run.

gvuksic
  • 2,983
  • 3
  • 32
  • 37
4

go to your StroyBoard. Right Click on your View Controller , delete the outlets with Yellow Exclamation Marks .

Abdul Waheed
  • 863
  • 8
  • 14