我正在制作一个小型的iOS应用程序,用于跟踪我工作时钟的时间。我对Swift和Xcode很陌生,所以这对我来说是一个挑战。详情:我正在使用Xcode 7,目标开发是8.3。我相信我缺少像类文件这样的小东西。 该应用程序在启动时崩溃。为什么我在setValue中获取NSUnknownKeyException:forUndefinedKey:?
错误:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key ButtonIn.'
代码:
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!"
}
}
检查与此视图控制器关联的xib。在xCode中搜索“ButtonIn”。你应该在那里找到它。 – ajmccall
是的,看起来你在故事板中有一些设置错误。你可以张贴你如何连接网点和操作的截图吗? –
此外,这是一个质量很低的问题。标题是多余的。请查看SO指导原则,否则您将无法获得答案,您的问题将被拒绝投票。 http://stackoverflow.com/help/how-to-ask – ajmccall