0

I am making a small iOS application that tracks the amount of time that I have clocked in at work. I am very new to Swift and Xcode, so this is being a challenge for me. Details: I am using Xcode 7, the target development is 8.3. I believe I am missing something small like a class file. The app crashes on start up.

Error:

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

Code:

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

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



    }
    @IBOutlet weak var Lb1: UILabel!

    @IBAction func ButtonIn(sender: AnyObject) {
        self.Lb1.text = "Clocked In!"
    }

    @IBAction func ButtonOut(sender: AnyObject) {
        self.Lb1.text = "Clocked Out!"
    }
}

enter image description here

enter image description here

enter image description here

  • 2
    Check the xib associated with this view controller. Search in xCode for "ButtonIn". You should find it there. – ajmccall Sep 21 '15 at 16:31
  • Yeah, looks like you have something setup wrong in the storyboard. Can you post screenshots of how you wired up the outlets and actions? – i_am_jorf Sep 21 '15 at 16:32
  • 1
    In addition, this is a very low quality question. The title is redundant. Please view SO guidelines otherwise you will not attract answers and your question will be down voted. http://stackoverflow.com/help/how-to-ask – ajmccall Sep 21 '15 at 16:32
  • Everything seems to be okay with your class afaik (except for conventions like methods beginning with small letters), so the issue is probably lying somewhere else. – Jeehut Sep 21 '15 at 16:38
  • I added screenshots, I do apologize for the low quality question, I am new. – Jacob Eggebeen Sep 21 '15 at 17:35

1 Answers1

1

This happens usually when the bind outlet is changed. Follow below mentioned steps:

  • Go to .xib file or storyboard scene for the class having this issue.
  • Select "File's Owner"
  • Select "Show the Connection Inspector" on the right panel
  • If you find any exclamation mark on ButtonIn connection then re-bind it.

Hope this helps.

enter image description here

Dharmesh Siddhpura
  • 1,610
  • 12
  • 22