How to access the Internet on an iPhone simulator?

I would like to access the internet on an iPhone simulator in xcode. I would like to check out some urls in my code.

How is this possible?

Thank.

+3
source share
4 answers

If you have an Internet connection on the development machine, the simulator uses this. There are no special things you need to do. Just make sure you are connected to the Internet using your mac

+10
source

if you ask to check your Internet connection, you can use the Reachability class, available throughout the Internet. He can tell you if internet / url is accessible or not.

+3
source

" URL- Safari ?". , :

NSURL *url = [NSURL URLWithString:@"http://www.google.com/"];
if (![[UIApplication sharedApplication] openURL:url])
    NSLog(@"%@%@",@"Failed to open url:",[url description]);

, .

+1

Remember that web page URLs must start with the http: // or https: // protocol indicator.

This is why the code

NSURL * url = [NSURL URLWithString: @ "www.google.com/"]

will not open Safari in the iOS simulator, whereas

NSURL * url = [NSURL URLWithString: @ "HTTP://www.google.com/"]

will be.

+1
source

Source: https://habr.com/ru/post/1783608/


All Articles