outlet删除不完全

今天在用iOS写个计算器的时候,遇到的一个小bug,新手,太新了,不之所错。

直接上码:

Terminating app due to uncaught exception 'NSUnknownKeyException', reason:

'[<SecondViewController 0x7f83435347d0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key txtscreen.'

造成错误的原因:

1、建了一个outlet:txtscreen;

2、然后想删除它,就把它的代码删了;

3、运行程序后,出现上述错误;

因为只在代码处删除该outlet,这是不完全的删除(既没有彻底的删除txtscreen),在该ViewController中还是有txtscreen,如图,一个小感叹号。

所以,如果出现类似的代码,那就是因为删除不彻底导致的。

解决办法:选中对应的ViewController的edit,右击,在Outlets中把该txtscreen删除就可以了。如图:

 

posted @ 2014-12-28 22:18  CasparJ  阅读(201)  评论(0编辑  收藏  举报