Guys i try to learn webview it can't load give me error like:
NSURLConnection finished with error - code -1022
- (void)viewDidLoad {
[super viewDidLoad];
NSString *urlString = @"http://www.sourcefreeze.com";
NSURL *url = [NSURL URLWithString:urlString];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[_webView loadRequest:request];
}
I think it is about App Transport Security.Because your url is not https.Try to change like this in the info.plist file
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
You are getting this error because you are not using https url. To fix follow below steps:
Add below line just before /dict:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
I was having a similar issue,
NSURLConnection finished with error - code -1200
I was trying to reach a blocked port in my company. Changing the port let me connect normally.
As pointed out below, disabling Firewall could also solve the issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With