Reputation: 237
I have a Label in my View. The Label's text must be the text on http://sample.com/file.html.
How to do this?
Upvotes: 0
Views: 198
Reputation: 4909
You can 'load' the contents of the URL directly into an NSString
:
NSString *text = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"http://sample.com/file.html"] encoding:NSUTF8StringEncoding error:&error];
And then set the label's text accordingly!
Upvotes: 2
Reputation: 17732
Try using NSData
's
+ (id)dataWithContentsOfURL:(NSURL *)aURL
Then convert to a string with NSString
's
- (id)initWithData:(NSData *)data encoding:(NSStringEncoding)encoding
Upvotes: 0