Q:

Function in AppDelegate.m file not getting called from MainViewController.m file

Using Cordova 2.1.0 for IOS app development.
I have following as my shouldStartLoadWithRequest function in MainViewController.m file:
- (BOOL)webView:(UIWebView *)webView2 
shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {

    NSLog(@"shouldStartLoadWithRequest function");

    // Intercept custom location change, URL begins with "js-call:"
    if ([[[request URL] absoluteString] hasPrefix:@"js-call:"]) {

        // Call the given selector
        [self performSelector:NSSelectorFromString(@"resetBadgeCount")];

        // Cancel the location change
        return NO;
    }

    // Accept this location change
    return YES;

}

The thing is, in my index.html i have following:-
    window.location = "js-call:resetBadgeCount";
But resetBadgeCount is a function existing in AppDelegate.m file and whenever shouldStartLoadWithRequest function is called, it gives this error:
-[MainViewController resetBadgeCount]: unrecognized selector sent to instance 0x199db0

So how should i change the code such that error suppresses and resetBadgeCount function is successfully invoked. 

A:

At the moment you're telling the MainViewController to try performing the selector.  That's why it's saying:
-[MainViewController resetBadgeCount]: unrecognized selector...
Try changing [self performSelector:...] to [[[UIApplication sharedApplication] delegate] performSelector:...]

