Reputation: 69
Is there a url (.txt) for the source code of each website?
If not, how can i get the source code of a webpage and be able to show it in a UITextView ?
Upvotes: 0
Views: 136
Reputation: 740
You should be able to use something like this:
NSString *googleString = @"http://www.google.com";
NSURL *googleURL = [NSURL URLWithString:googleString];
NSError *error;
NSString *googlePage = [NSString stringWithContentsOfURL:googleURL
encoding:NSASCIIStringEncoding
error:&error];
This will put the contents of the google home page into googlePage
and, if applicable, the error into error
. If the page being loaded uses Unicode characters, try NSUTF8StringEncoding
instead of NSASCIIStringEncoding
.
Upvotes: 1