Home > Enterprise >  How to load HTTP content in Webkit
How to load HTTP content in Webkit

Time:12-16

How to load HTTP content in Webkit in objective-c?

The code I use:

NSString *loadedURL = @"http://www.apple.com";

NSURL *targetURL = [NSURL URLWithString:loadedURL];

NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];

[_webView loadRequest:request];

If i post a link "https://www.apple.com" (with httpS) its open correctly, but from HTTP not. Can you help me?

CodePudding user response:

Please check whether the App Transport Security restrictions are disabled for all network connections, which means that unsecured http connections may be allowed.

Steps:

  1. Opened my Projects info.plist file

  2. Added a Key called NSAppTransportSecurity as a Dictionary.

  3. Added a Subkey called NSAllowsArbitraryLoads as Boolean and set its value to YES as like following image.

enter image description here

Now clean the Project and Now Everything will Run fine as like before.

  • Related