0
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIView 0x104908040> `setValue:forUndefinedKey:`]: this class is not **key value coding-compliant** for the key signinbutton.'

I'm getting an error after building and launching my iOS app. I see that other people have got this error before, but after trying all the solutions, none of them have worked for me. It's not a naming issue, or a bad connection, as far as I can tell. I've deleted the app, restarted, etc. I've tried with different outlets. This is how it goes: my app works perfectly, then I add any sort of @IBOutlet to my ViewController, all looks good. Build and run, and the app loads to a blank screen and I get that error in my console.

I've been trying every solution on stackoverflow for the past 6 hours. None of them work.

This is my ViewController.

import UIKit

class UIView: UIViewController {

    @IBOutlet weak var signInButton: UIButton!
    override func viewDidLoad() {
        super.viewDidLoad()
    }

}

My AppDelegate file is just as it comes default.

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

and so on...

Why isn't this working?

EDIT: Changing the class to class HomeViewController: UIViewController does nothing.

Note: This is not a duplicate question. No solution posted on Stack Overflow has worked so far for me.

esalberg
  • 23
  • 2
  • 5
  • change your classname from `UIView` to something else that is not a part of ios default keywords – Krunal Mar 19 '18 at 06:18
  • In the formulation of your edit, you say _not a duplicate question_ and _no solution posted [...] has worked_, which is a bit contradictory: how can there be solutions posted already if there wasn't this question before? – Cœur Mar 19 '18 at 08:16

4 Answers4

2

Change the name of your controller to some name.

class UIView: UIViewController // This is wrong

class HomeViewController: UIViewController : This is right

Also update the class of controller in storyboard: Select controller in storyboard. Change file's owner.

Cœur
  • 37,241
  • 25
  • 195
  • 267
pkc456
  • 8,350
  • 38
  • 53
  • 109
  • 1
    How do I update the class of the controller in the storyboard? – esalberg Mar 19 '18 at 06:13
  • 1
    Select controller in storyboard. Change `file's owner` – pkc456 Mar 19 '18 at 06:14
  • @pkv456 mention above in his answer to change class name and also set that name in storyboard. – Rishil Patel Mar 19 '18 at 06:14
  • @pkc456 Do you mean "View Controller"? Using Xcode version 9.2 I don't see any option to change the file's owner. Also, what do I change it to? – esalberg Mar 19 '18 at 06:20
  • 1) Open storyboard. 2) Click on controller where you declared `signInButton` 3) On the left panel, you will see File's owner. Click on it. 4) On the right panel, there is option to change the class of controller – pkc456 Mar 19 '18 at 06:23
  • @esalberg - “File owner” is used in NIBs. It’s the “base class” in a storyboard scene. Are you using NIB or storyboard? – Rob Mar 19 '18 at 06:24
  • @Rob I don't think I"m using NIBs. I've found where the "File owner" _should_ be (In the Document Outline) but there's nothing there. Just the Home View Controller Scene, and it's children. What do I do know that I know I have **no** File owner? – esalberg Mar 19 '18 at 06:36
  • 1
    @esalberg - When you select the UI in the project navigator panel in the left, does it have an extension `.xib` or `.storyboard`? If a storyboard, you are _not_ going to look for the “file owner”. It’s called that for NIBs, but not storyboards. I’m presuming you’re dealing with storyboard. So, select the view controller in the “document outline” of your storyboard, go to the “identity inspector” in the panel on the right, and check out the “Custom Class” section and supply your new view controller class name as the “class” for that storyboard scene. – Rob Mar 19 '18 at 06:57
0

Kindly create the outlet of signinbutton in your view controllerTo Learn more about outlets and Actions

Waqas Sultan
  • 884
  • 5
  • 13
0

Simple, if your class is a UIView, either subclass UIView or your custom UIView subclass.

If your class is a UIViewController, either subclass UIViewController or your custom UIViewController subclass.

UIView: UIViewController doesnt make sense to the compiler.

I would like to mention some background info:

x : y means, x is a subclass of y, since you mention it is your ViewController file, so in order for your code to compile, you can simply change the name of your class from UIView to a custom name

Also UIViewController is another Class in UIKit, just like UIView or UITableView, but not the controller of the child class. Meanning when x : y, y is not the controller of x, but indeed x is the controller, and x is subclassed from Y

Edison Lo
  • 476
  • 8
  • 25
0

Don't use UIView as the class name, because there's a system of UIView classes.

TW520
  • 86
  • 6