Swift "this class is not key value coding-compliant for the key" 中的图像选择器错误

Error With Image Picker in Swift "this class is not key value coding-compliant for the key"

尝试在 Swift 中创建图像选择器时,用户按下按钮并选择图像,我遇到了这个错误:

'NSUnknownKeyException', reason: '[<MemeGenerator.ViewController 0x7ff3805a6f10> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key selectedImage.'

我的视图控制器 class 是 here

知道出了什么问题吗?如有必要,我可以提供更多文件。

通常,该消息意味着您在 IB(界面生成器)中在控件和代码中定义的 IBOutlet 之间连接了一个 IBOutlet link,然后删除了该插座。在运行时,系统尝试连接 link 失败。

查看 IB 中视图控制器中的所有出口(以及 IBActions)并查找损坏的 links。