0

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.

2
  • Step through your init method and find the exact line which throws the exception. Just post the code here... That's the easiest way to find the solution.
    – tamasgal
    Apr 8, 2011 at 11:13
  • It happens when it is loading from the nib in the int retVal = UIApplicationMain(argc, argv, nil, nil); line of the main method.
    – pajevic
    Apr 8, 2011 at 11:30

2 Answers 2

0

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

1
  • Hello Rajat. Sorry for the late reply, but we had a rare weekend with good weather so I didn't do any work :) Anyway, I checked all the classes and they are correct. As I stated in my question, the xib worked just fine in another project (in Xcode 3); in fact the app is even in the App Store.
    – pajevic
    Apr 11, 2011 at 6:06
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.