0

I have next to no knowledge of Objective-C, but I'm using Cordova (PhoneGap) to create a web app and needed to manipulate the headers sent by their InAppBrowser plugin.

I have managed to get custom headers to send with the request, I changed the NSURLRequest to a NSMutableURLRequest and then set a custom header like this:

NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:url]; 
[request setValue:@"test" forHTTPHeaderField:@"Accept-Encoding"];

My next problem was passing the headers from the javascript. I added an additional option to the parameters. The parameters need to be passed along between several functions (or methods?) before they get to the place where I can manipulate the headers. I've managed to pass them through several functions, and NSLog is still showing me the correct value that I sent from my javascript, but I've fallen at the final hurdle. I can't pass an additional parameter to my final function!

I have this bit of code here:

[self.inAppBrowserViewController navigateTo:url withHeaders:headers ];

Which calls the navigateTo function that is defined like this:

- (void)navigateTo:(NSURL*)url withHeaders:(NSString*)headers
{
    NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:url];
    [request setValue:@"test" forHTTPHeaderField:@"Accept-Encoding"];
    if (_userAgentLockToken != 0) {
        [self.webView loadRequest:request];
    } else {
        [CDVUserAgentUtil acquireLock:^(NSInteger lockToken) {
            _userAgentLockToken = lockToken;
            [CDVUserAgentUtil setUserAgent:_userAgent lockToken:lockToken];
            [self.webView loadRequest:request];
        }];
    }
}

The problem I have is that the line that calls navigateTo is giving me the error: "CordovaLib/Classes/CDVInAppBrowser.m:149:6: No visible @interface for 'CDVInAppBrowserViewController' declares the selector 'navigateTo:withHeaders:'"

4

1 回答 1

1

将 CDVInAppBrowserViewController.h 中的方法声明为

- (void)navigateTo:(NSURL*)url withHeaders:(NSString*)headers;
于 2013-07-24T12:57:52.617 回答