would like to be able to load a website without loading it in Safari (for server call purposes)
I tried theses two methods but they don t work at all :
NSString *connected = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"http://www.google.com"] encoding:NSStringEncodingConversionAllowLossy error:nil];
and
NSURL *URL = [NSURL URLWithString:@"http://www.google.com"];
NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:URL];
NSURLResponse *response = nil;
NSError *error = nil;
NSData *data = [NSURLConnection sendSynchronousRequest:req returningResponse:&response error:&error];
but both these options don t load the website unfortunatley , any reasons ?
If you are trying to display the webpage, you should check out the UIWebView class or WebView class on OS X.
You may find the following sample code to be useful, PrintWebView (OS X), UICatalog (iOS).
If you are trying to download the HTML source of the webpage, then you really don’t want to be using
stringWithContentsOfURL:. It will block the main thread, for more information see Synchronous Networking on the Main Thread.