I am starting a very simple learning application and I am working with NSURLConnection and have started looking into reading the contents of a file for example, http://www.funnynewsletter.tk/files/files.txt and reading them as a String into Objective C.
I am wondering how to do this and print the saved string onto a label, “label”.
Can anyone help me out?
Here is my current code.
- (void) viewDidUnLoad
{
NSError* e;
NSString *str = [NSString stringWithContentsOfURL:@"http://funnynewsletter.tk/files/files.txt"];
if(e != nil) {
NSLog(@"Error");
}
label.text = self.str;
}
This has errors on line 4 and 8. I have no clue what is going on. Can anyone help?
You are sending
NSStringinstead ofNSURL.try this…