I want get html from url and I use:
NSString *URLtoHTML = [NSString stringWithContentsOfURL:self.url encoding:NSUTF8StringEncoding error:nil];
[self.webView loadHTMLString:URLtoHTML baseURL:nil];
But after this my cookies clean in UIWebView. But if i use load request without stringWithContentsOfURL cookies save:
[self.webView loadRequest:[NSURLRequest requestWithURL:self.url]];
I have tried it but cookies not save too:
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
[receivedData appendData:data];
NSString *dataString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
}
How do I get a HTML and load it in UIWebView with cookies?
UPDATE: If i use this case (two unrelated lines) cookies not save too:
NSString *URLtoHTML = [NSString stringWithContentsOfURL:self.url encoding:NSUTF8StringEncoding error:nil];
[self.webView loadRequest:[NSURLRequest requestWithURL:self.url]];
i.e. stringWithContentsOfURL
does not save cookies. How can this be? it's funny :D