this class is not key value coding-compliant for the key XXX

后端 未结 2 1824
心在旅途
心在旅途 2021-01-28 17:48

I\'m a beginner in everything programming and have been trying to implement some self learned stuff from the Big Nerd Ranch Books. But I\'m really stumped by this problem, and y

相关标签:
2条回答
  • 2021-01-28 18:14

    When this error message appears it is very often a bad connection in a xib file or storyboard. I'll guess that this is an old example that has a MainWindow.xib file in it, with the File's Owner set as the UIApplication class. There is most likely a connection in that xib to an outlet called repsField in the File's Owner which, of course, does not match anything in the actual class.

    0 讨论(0)
  • 2021-01-28 18:17

    Looks like the problem is that someone is accessing the UIApplication instance with a key (repsField) that is not KVC compliant.

    Update I don't think you even need to subclass to add a breakpoint. Go to the breakpoint navigator and add a symbolic breakpoint for symbol -[UIApplication setValue:forUndefinedKey:] and then run the application.

    I think you can debug it by subclassing UIApplication and set a breakpoint in a dummy override of the setValue:forUndefinedKey: method.

    In the file where you call UIApplicationMain add this class:

    @interface TestApplication : UIApplication
    @end
    @implementation TestApplication
    - (void)setValue:(id)value forUndefinedKey:(NSString *)key {
        [super setValue:value forUndefinedKey:key]; // set breakpoint here
    }
    @end
    

    And then change the third argument to UIApplicationMain to @"TestApplication", for example:

    UIApplicationMain(argc, argv, @"TestApplication", NSStringFromClass([AppDelegate class]));
    

    Now run the application and it should break into to debugger and you should be able to see the call stack causing it.

    0 讨论(0)
提交回复
热议问题