I am looking for anything like .NET WebClient: Where is DownloadString? on XCode.
Just one URL to send and one String to get. I have working solution on iPhone and one on Mac Project but on iPad it does not work.
I found https://github.com/pokeb/asi-http-request but it throws errors in XCode 4.1 about release is not supported
.
Any suggestions to download website on iPad project with HighLevel access?
What class an be used in case of ASIHTTPRequest?
-(NSString*) DownloadString:(NSString *)UrlString;
{
NSURL *url = [NSURL URLWithString:UrlString];
// Create a request
ASIHTTPRequest* myRequest = [ASIHTTPRequest requestWithURL:url];
// Start the request
[myRequest startSynchronous];
// Request has now finished
NSString *Result = [myRequest responseString];
return Result;
}
* SOLUTION (thanks to Francesco) *
NSString *UrlTargetString = @"http://www.goldengel.ch";
NSURL *UrlTarget = [NSURL URLWithString: UrlTargetString];
NSError* error = nil;
NSString* text = [NSString stringWithContentsOfURL:UrlTarget encoding:NSASCIIStringEncoding error:&error];
if( text )
{
NSLog(@"Text=%@", text);
}
else
{
NSLog(@"Error = %@", error);
}
Response / Log is:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>....</html>