iosobjective-cibactionnsunknownkeyexception

Terminating app due to uncaught exception 'NSUnknownKeyException' after deleting IBAction


I recently added an IBAction to my ViewController by Ctrl+Dragging a button into the .h file of the ViewController. I then deleted the line from the .h file, as I realised I didn't need it, but I believe this has caused the following error when I Run the app:

2014-09-21 12:24:21.331 Fullscreen Ninja Browser for iPhone 6[5863:298888] ***
Terminating app due to uncaught exception 'NSUnknownKeyException', reason:
'[<ViewController 0x7fe04bc1fcb0> setValue:forUndefinedKey:]: this class is not key
value coding-compliant for the key backButton.'  

Does anyone know how to fix this issue?

Edit: I will delete this issue from the question once it is solved:

I have created some simple code designed to show a webpage, which has been working perfectly fine since I created it. However, when I now run the app, the UIWebView no longer displays the webpage, although the NSLog shows the code is definitely being run.

In the .h: @property (weak, nonatomic) IBOutlet UIWebView *webView;

In the .m:

@synthesize webView;

- (void)viewDidLoad {
NSString *url = @"http://www.google.com";
[self createWebpage:url];

self.addressBar.delegate = self;

[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}

- (void) createWebpage:(NSString *)webString {
    NSURL *url = [NSURL URLWithString:webString];
    NSURLRequest *requestUrl = [NSURLRequest requestWithURL:url];
    [self.webView loadRequest:requestUrl];
    NSLog(@"Webpage is created!");
}  

To my knowledge, I haven't changed any of the code, and the NSLog tells me the code is definitely running. How can I solve this problem?


Solution

  • The problem is that your button stills is connected to that method. Click the button in Interface Builder, choose the Connections view in the Inspector on the right and remove the connection.