Exception on outlet connections in Xcode 4

拟墨画扇 提交于 2019-12-12 04:15:50

问题


I have created a new iPhone project in Xcode 4 and added some files (xib and classes) from an old project which was created in Xcode 3 which works fine.

The project compiles fine with no errors or warnings. However, when I try to run it I get the infamous "NSUnknownKeyException reason: class is not key value coding-compliant for the key dateOutlet" error.

When I opened the XIB file the connection to the dateOutlet seemed just fine, but I deleted and reconnected anyway just to be safe. Next time I ran it I got the same error but on another outlet which made me think that something went wrong with connections and I just needed to reconnect them again. However, I noticed that sometimes when I reconnected an outlet it would fail on an outlet which I had already ìfixedî. After a lot of fiddling I concluded that reconnecting didnít really fix anything, itís just that when I made changes to the xib the next failing outlet would be picked at random (or so it seems at least).

Has anybody experienced this problem? I have googled a lot but none seem to have encountered this exact behaviour. I have tried to run the project on 3 different machines now with the same result.


回答1:


The class property of the object should be set properly in the xib file,

for ex if you are connecting an iboutlet of uiimageview to an imageview Object in xib, cross check that the class property of that object(opened by pressing command+4) in xib is set to UiImageview




回答2:


Ok, I found out the source of the problem. It seems that in the Target for the app the “Main Interface” was set to my MainView which is an instance of UIView. I changed it to MainWindow (generated by Xcode) and all worked fine.



来源:https://stackoverflow.com/questions/5594200/exception-on-outlet-connections-in-xcode-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!