I've spent a few hours searching for a solution to this problem but I can't even seem to find anyone who's experienced it, let alone a solution.
In my project, I have a main view controller that pushes a second view controller containing a UIWebView. Both view controllers are embedded in a navigation controller. The push segue and WebView are both hooked up using IB.
The segue happens as expected and the web page loads and works fine until I try to type. Tapping on a text field brings up the keyboard, but the first key press crashes the app and gives the error:
-[NSNull length]: unrecognized selector sent to instance 0x1899068
2014-02-06 04:37:19.550 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull length]: unrecognized selector sent to instance 0x1899068'
*** First throw call stack:
(
0 CoreFoundation 0x0174d5e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x014d08b6 objc_exception_throw + 44
...
This happens both in the Simulator and on device. I'm particularly confused because I'm not doing anything remotely complex. In the view controller that contains the WebView, I have the following viewDidLoad:
- (void)viewDidLoad {
[super viewDidLoad];
NSURL *url = [NSURL URLWithString:@"http://www.google.com"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[self.webView loadRequest:request];
}
and no other code. Google is used as an example site here, but it happens on every site I've tried. The weird thing is that if I remove the segue and present the Web View without the parent Navigation Controller, everything works fine, so it seems like the nav controller has something to do with it. As I said, the webView property is hooked up as an IB outlet. I've also tried adding it programatically, but the outcome was the same. As far as I can tell nothing in my first view controller should have any effect on this; like I said it's a Storyboard segue from a button. I can be sure sending length to NSNull is not anything I'm doing directly by myself, as I don't use the length selector anywhere in my code.
Any help would be greatly appreciated.
It was requested so the full error message is as follows:
-[NSNull length]: unrecognized selector sent to instance 0x1899068
2014-02-06 05:18:29.607 AppName[859:70b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull length]: unrecognized selector sent to instance 0x1899068'
*** First throw call stack:
(
0 CoreFoundation 0x0174d5e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x014d08b6 objc_exception_throw + 44
2 CoreFoundation 0x017ea903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x0173d90b ___forwarding___ + 1019
4 CoreFoundation 0x0173d4ee _CF_forwarding_prep_0 + 14
5 CoreFoundation 0x016cd95c CFStringGetLength + 140
6 CoreFoundation 0x016e1284 CFStringCompareWithOptionsAndLocale + 52
7 Foundation 0x010db634 -[NSString compare:options:range:locale:] + 175
8 Foundation 0x010db580 -[NSString compare:options:range:] + 69
9 Foundation 0x010eda59 -[NSString caseInsensitiveCompare:] + 80
10 UIKit 0x00454f48 -[UIPhysicalKeyboardEvent _matchesKeyCommand:] + 280
11 UIKit 0x00398ac9 -[UIResponder(Internal) _keyCommandForEvent:] + 312
12 UIKit 0x00398b3b -[UIResponder(Internal) _keyCommandForEvent:] + 426
13 UIKit 0x00398b3b -[UIResponder(Internal) _keyCommandForEvent:] + 426
14 UIKit 0x00398b3b -[UIResponder(Internal) _keyCommandForEvent:] + 426
15 UIKit 0x00398b3b -[UIResponder(Internal) _keyCommandForEvent:] + 426
16 UIKit 0x00398b3b -[UIResponder(Internal) _keyCommandForEvent:] + 426
17 UIKit 0x00398b3b -[UIResponder(Internal) _keyCommandForEvent:] + 426
18 UIKit 0x00398b3b -[UIResponder(Internal) _keyCommandForEvent:] + 426
19 UIKit 0x00398b3b -[UIResponder(Internal) _keyCommandForEvent:] + 426
20 UIKit 0x00252176 -[UIApplication handleKeyHIDEvent:] + 226
21 UIKit 0x0023a07c _UIApplicationHandleEventQueue + 2954
22 CoreFoundation 0x016d683f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
23 CoreFoundation 0x016d61cb __CFRunLoopDoSources0 + 235
24 CoreFoundation 0x016f329e __CFRunLoopRun + 910
25 CoreFoundation 0x016f2ac3 CFRunLoopRunSpecific + 467
26 CoreFoundation 0x016f28db CFRunLoopRunInMode + 123
27 GraphicsServices 0x036f29e2 GSEventRunModal + 192
28 GraphicsServices 0x036f2809 GSEventRun + 104
29 UIKit 0x0023ed3b UIApplicationMain + 1225
30 AppName 0x00003d3d main + 141
31 libdyld.dylib 0x01d8b70d start + 1
32 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException