我尝试按照here提到的说明将UI组件连接到我的视图控制器。虽然,每当我生成行
@IBOutlet weak var mt: UITextView!
当我运行我的app时,在使用消息
启动segue后的SIGABRTTerminating app due to uncaught exception 'NSUnknownKeyException',
reason: '[<UIViewController 0x10336c400> setValue:forUndefinedKey:]:
this class is not key value coding-compliant for the key mt.'
我查看了其他帖子,这可能不是死链接,因为我刚刚创建它,当我删除引用插座时,应用程序不再崩溃。
有人可以告诉我如何解决这个问题吗?所有相关代码如下。
的ViewController
performSegue(withIdentifier: "mySegueID", sender: nil)
...
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if (segue.identifier == "mySegueID") {
if let destinationViewController = segue.destination as? MessageViewController {
destinationViewController.message = "Hi friend"
}
}
}
MessageViewController
import UIKit
class MessageViewController: UIViewController {
var message:String = "default"
@IBOutlet weak var mt: UITextView!
override func viewDidLoad(){
super.viewDidLoad()
mt.text = message
}
}
提前谢谢!