的setValue:forUndefinedKey:]:

Szw*_*edo 20 xcode viewcontroller sigabrt modalviewcontroller

FinalViewWithSending *newView = [[FinalViewWithSending alloc]initWithNibName:@"FinalViewWithSending" bundle:nil];
newView.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:newView animated:YES]; //it crashes here with a thread 1 error, SIGABRT error..
Run Code Online (Sandbox Code Playgroud)

它说:

"Terminating app due to uncaught exception 'NSUnknownKeyException', 
reason: '[<FinalViewWithSending 0x1bef70> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key loginButton.'"
Run Code Online (Sandbox Code Playgroud)

没有名为loginButton的变量,所以我不知道为什么我会收到错误...

谢谢

Phi*_*lls 34

您收到错误,因为没有名为loginButton的属性.检查.xib文件.几乎可以肯定的是,一个指向loginButton的FinalViewWithSending对象(可能是File的所有者)的链接很糟糕,即使它在类代码中不存在.


小智 9

菲利普米尔斯是对的​​.

对于任何搜索,这里的答案是编辑故事板并删除指定的未定义键的任何链接.您必须在外部编辑器中编辑故事板文件:右键单击层次结构中的故事板列表,然后单击"在查找器中显示"或您拥有的内容.在文本编辑器中打开,通过搜索,保存并返回Xcode来删除所述链接.没有更多的问题.

当您从视图控制器中不正确地删除某些内容时会发生这种情况.

  • 对于这里的新手,您不必打开文本编辑器并编辑故事板。View-&gt;Utilities-&gt;Show Connections Inspector 点击不同的按钮,看看坏的连接 (2认同)

Sno*_*ash 8

同意这里 - 菲利普米尔斯是正确的.

有人提到在文本编辑器中打开故事板 - 这不是必需的.

只需单击故事板,转到Connections Inspector即可.如果你有一个有问题的插座,你会在插座旁边看到一个惊叹号.删除它.


Jos*_*nce 5

由于这是此错误的第一个搜索结果,因此我决定为像我这样的菜鸟写一个答案。

如果您从Button中按住Ctrl键拖动了连接,这将在ViewController中生成代码,然后仅删除代码而不删除连接,则会出现此错误。

我收到此错误的原因是,当我想将它们添加为“动作”时,不小心添加了一些按钮作为“插座”。我删除了生成的代码,但不良连接仍然存在。

要查找和删除它们,请查看->实用程序->显示连接检查器

然后单击您拥有的其他按钮,然后单击x删除错误的连接。

在此处输入图片说明