0

I am building an ASIHttpRequest to set the credentials.

My next step is to reuse this request und load an HTML Site with:

[webView loadRequest:<#(NSURLRequest *)#>]

But this is not working with ASIHTTPRequest...

Also I tried to this:

[self.webView loadData:[asiRequestWebView responseData] MIMEType:@"text/html" textEncodingName:@"UTF-8" baseURL:targetURL];

But still its not working.

And I can't use the ASIWebpageRequest because its not very stable....

Please I need some ideas..

EDIT:

@gardenofwine

Thank you very much. I ended up doing what you said:

[webView loadRequest:[NSURLRequest requestWithURL:[asihttprequest url]]];

But told the request before:

asiRequest.useKeychainPersistence = YES;

Now it works like a charm thank you very much!

verklixt
  • 691
  • 5
  • 13

1 Answers1

0

Can you further explain what exactly did not work, and supply the console log? (compile error, runtime error, crash?)

Can you explain why the following code does not do what you need?

[webView loadRequest:[NSURLRequest  requestWithURL:[asihttprequest.url]]];
gardenofwine
  • 1,314
  • 2
  • 15
  • 24
  • Wow That was fast. I endet up doing: [webView loadRequest:[NSURLRequest requestWithURL:[asiRequestWebView url]]]; This is my error: WEbviewDIDFAILLOADwithError: Error Domain=NSURLErrorDomain Code=-999 "The operation couldn’t be completed. (NSURLErrorDomain error -999.)" UserInfo=0x4c346b0 {NSErrorFailingURLKey=https://SOMEURL.html, NSErrorFailingURLStringKey=https://SOMEURL.html} The asiRequest I reused from before where I already had the right credentials. The request should be persistent?! – verklixt Aug 18 '11 at 15:29
  • If I use: asiRequestWebView = [ASIHTTPRequest requestWithURL:self.targetURL]; NSLog (@"Request Infromations: %@", [asiRequestWebView url]); [asiRequestWebView setDelegate:self]; [webView loadRequest:[NSURLRequest requestWithURL:[asiRequestWebView url]] Only -(void)webViewDidStartLoad:(UIWebView *)webView Is called! – verklixt Aug 18 '11 at 15:41
  • I solved the problem and will post it soon, thank you @gardenofwine for you suggestion. – verklixt Aug 18 '11 at 15:47
  • Oh man, now I have the problem that the Page doesn't fit properly in my Webview. even when I say [webView setScalesPageToFit:YES]; that wasn't before when I had this(before using ASIHttpRequest): NSURLRequest *request = [NSURLRequest requestWithURL:targetURL]; [webView loadRequest:request] Any ideas? – verklixt Aug 18 '11 at 16:05
  • I'm glad to hear you figured it out. About the html page not fitting, I would suggest you try and compare the 2 html pages (one by loading from NSURLRequest, the othrer from ASIHttpRequest), likewise: – gardenofwine Aug 21 '11 at 07:39
  • [webView stringByEvaluatingJavascriptString:@"document.body.innerHtml"]; plus, if you feel my answer worked for you, please mark it as "this answers my question" for my hall of fame :-) – gardenofwine Aug 21 '11 at 09:08
  • That was kind of confusing. I had an WebView instance in my class and said: self.webview = ..... Now Iam only saying: webview= ...... And now the Page fits perfect... Does somebody know what the trick is behind the self. ? – verklixt Aug 26 '11 at 10:45
  • 1
    see this thread on the way Objective-C accessors work: http://stackoverflow.com/questions/2616581/objective-c-getter-setter-question – gardenofwine Aug 28 '11 at 11:35