I have a standalone UIViewController
with a UIWebView
. I need to check if a certain URL has been hit, and if so, present a new UIViewController
inside of a UINavigationController
.
Here is my code:
-(BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType {
NSURL *url = request.URL;
NSString *urlString = url.absoluteString;
//Check if special link
if ( [ urlString isEqualToString: @"http://www.mysite.com/store" ] ) {
//Here present the new view controller
StoreViewController *controller = [[StoreViewController alloc] init];
[self presentViewController:controller animated:YES completion: nil];
return NO;
}
return YES;
}
However, when I run the app, I get the following error:
WebKit threw an uncaught exception in the method webView:decidePolicyForNavigationAction:request:frame:decisionListener: delegate:
<'NSInvalidArgumentException'> * -[__NSArrayM insertObject:atIndex:]: object cannot be nil
If I try and open the UINavigationController
itself it works fine...but then how do I pass data to the StoreViewController
itself?