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

后端 未结 2 1823
心在旅途
心在旅途 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: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.

提交回复
热议问题