0

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?

Isaac A
  • 361
  • 2
  • 24

1 Answers1

1

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.

idmean
  • 14,540
  • 9
  • 54
  • 83
  • I did this, and also deleted the IBActions from the h file, but the error is still there. Should I also delete the Referencing Outlet connection between the button and the View Controller? – Isaac A Sep 21 '14 at 11:50
  • @IsaacA No you don't have to delete outlets, only the action. Did you try cleaning the project and then rebuilding? – idmean Sep 21 '14 at 11:52
  • Damn. I deleted the referencing outlet, and I don't know how to put it back - I have a feeling I shouldn't have done that :\ Although it's running the app know, which I suppose is good. Any idea how to reconnect the referencing outlet, however? – Isaac A Sep 21 '14 at 11:53
  • @IsaacA Open the assistant editor and ctrl-drag to the outlet. – idmean Sep 21 '14 at 11:58
  • Thanks a lot for the help! :) I know this may be pushing it a bit, but I haven't got much time at all today, so would you be able to help me with a small problem I have? I included it in a temporary edit. – Isaac A Sep 21 '14 at 12:10
  • @IsaacA It's difficult to tell what is wrong with your code. Maybe url is nil. Did you checked that? I've got a question too: You are using code which I provided in an [answer yesterday](http://stackoverflow.com/questions/25948529/use-of-undeclared-identifier-xcode/25948563#25948563), additionally the user name is very similar to yours. Are you having two accounts? – idmean Sep 21 '14 at 12:27
  • Yeah, that's my account :P Is it against site rules to have two accounts..? – Isaac A Sep 21 '14 at 12:38
  • @IsaacA Well, basically you are allowed to have to accounts but it's not considered good. But as long as you don't use them for gaining reputation it's not against the rules. – idmean Sep 21 '14 at 12:40
  • @IsaacA If my answer has solved your question please consider [accepting it](http://meta.stackexchange.com/q/5234/179419) by clicking the check-mark. This indicates to the wider community that you've found a solution and gives some reputation to both me and yourself. There is no obligation to do this. – idmean Sep 28 '14 at 12:32