0

I'm trying to create an app that starts from a main page with three buttons on it. Each button pressed will switch to another view. Each view is just a blank view with a UIWebView on it. Transitioning to each page works fine when there's nothing on it. However, when I add the UIWebview and all the correct code, the transition to the page causes the app to crash with this error message:

* Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key viewWeb.' * First throw call stack: (0x1c94012 0x10d1e7e 0x1d1cfb1 0xb7de41 0xaff5f8 0xaff0e7 0xb29b58 0x233019 0x10e5663 0x1c8f45a 0x231b1c 0xf67e7 0xf6dc8 0xf6ff8 0xf7232 0x259b 0x10e5705 0x192c0 0x19258 0xda021 0xda57f 0xd96e8 0x48cef 0x48f02 0x26d4a 0x18698 0x1befdf9 0x1befad0 0x1c09bf5 0x1c09962 0x1c3abb6 0x1c39f44 0x1c39e1b 0x1bee7e3 0x1bee668 0x15ffc 0x1e92 0x1dc5) libc++abi.dylib: terminate called throwing an exception

I'm positive all the UIWebView code is correct since I tested the exact same code in a new app that just runs on a single view and has no transitions. But here's the code I'm using for the transition:

- (IBAction)floorCatalog:(id)sender {
UIViewController* floorLampsViewController = [[UIViewController alloc] initWithNibName:@"floorLampsViewController" bundle:[NSBundle mainBundle]];
[self.view addSubview:floorLampsViewController.view];
} 
- (void)dealloc {
[_floorLampsButton release];
[_tableLampsButton release];
[_wallLampsButton release];
[super dealloc];
}
- (void)viewDidUnload {
[self setFloorLampsButton:nil];
[self setTableLampsButton:nil];
[self setWallLampsButton:nil];
[super viewDidUnload];
}

And here's the code I'm using for the web views:

@property (retain, nonatomic) IBOutlet UIWebView *viewWeb;
[self.viewWeb loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.bing.com"]]];

Any reason why this keeps happening? Thanks!

Generalkidd
  • 579
  • 1
  • 8
  • 22
  • possible duplicate of [This class is not key value coding-compliant for the key](http://stackoverflow.com/questions/3088059/this-class-is-not-key-value-coding-compliant-for-the-key) – jtbandes Aug 01 '15 at 21:51

1 Answers1

0

Is viewWeb hooked up to the UIWebView in Interface Builder? It looks like viewWeb wasn't initialized or something, and seeing you're using an IBOutlet it makes me think it's in your nib.

Stakenborg
  • 2,890
  • 2
  • 24
  • 30
  • Where would I initialize viewWeb? I though that's all I needed to make UIWebView work and indeed in a separate app that's just purely the webview with no buttons or transitions, the WebView works. – Generalkidd Jul 18 '13 at 21:45
  • It seems like in your Interface Builder either viewWeb isn't actually a UIWebView (or something) or it isn't hooked up to your view controller at all. If it's hooked up properly in IB you won't have to do anything in code to initialize it, if not, you wind up getting errors similar to the one you're seeing. – Stakenborg Jul 18 '13 at 21:47
  • I'm positive it's hooked up correctly. I've repeated the exact same process in a separate project and the UIWebView works perfectly. It was a single-view app though. When I try the same process in a multi-view app, the same process doesn't work anymore. – Generalkidd Jul 23 '13 at 20:44