iosxcodeuiviewcontrollerxibnsunknownkeyexception

UIViewController setValue:forUndefinedKey: with deleted xib


I recently deleted the xib for a particular UIViewController subclass. However, since then I have been getting the following error on device only, and not simulator:

*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<CustomWebViewController 0x192494d0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key btnBack.'

I had set btnBack as an IBOutlet before in the XIB, and have since removed that property.

The XIB is deleted and I have cleaned the project countless times, but this issue still persists.

How can I go about finding where in my code this property is being set, or cleaning up this issue in XCode?

EDIT: To make this clear:


Solution

  • I don't know what really happened, but I hadn't yet overridden the -init method int the class.

    After overriding all the init methods like so:

    -(instancetype)init
    {
        if (self = [super init])
        {
    
        }
    
        return self;
    }
    
    -(instancetype)initWithCoder:(NSCoder *)aDecoder
    {
        if (self = [super initWithCoder:aDecoder])
        {
    
        }
    
        return self;
    }
    
    -(instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
    {
        if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])
        {
    
        }
    
        return self;
    }
    

    Everything worked fine.