Philip
Philip

Reputation: 39

Best way loading HTTPS:// website into UIWebView?

What is the best way to load a website into a webview by using https? Is there a easy way to do so?

Thanks

Philip

Upvotes: 1

Views: 3146

Answers (1)

Chris Cashwell
Chris Cashwell

Reputation: 22859

The easiest way I know of is...

NSString *urlAddress = @"https://www.google.com";

//Create a URL object from the string 'urlAddress'
NSURL *url = [NSURL URLWithString:urlAddress];

//Create a URL Request Object from NSURL object 'url'
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];

//Load the NSURLRequest object 'requestObj' in the UIWebView.
[webView loadRequest:requestObj];

And of course you can condense this into a one-liner...

[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"https://www.google.com"]]];

Upvotes: 1

Related Questions