I am trying to read the text from this file and display it in a label on my app. I am getting an error message with this piece of code.
NSURL *url = [NSURL URLWithString:@"http://www.funnynewsletter.tk/files/file.txt"];
NSString *content = [NSString stringWithContentsOfURL:url encoding:NSASCIIStringEncoding];
label.text = content;
I know, it’s simple. I’m just starting out learning iOS and I’m trying. If you could give me sources and ideas, not full code, that would be appreciated… I’m trying to learn, not just copy your work. Thanks everyone! 🙂
Error Message: No known class method for selector 'stringWithContentsOfUrl:encoding'
The error message is telling you that the class NSString has no method of that name. The proper method is
stringWithContentsOfURL:encoding:error:. I think there used to bestringWithContentsOfURL:encoding:but it was deprecated and then removed. If you’re just testing and don’t care about the error, you can passnilforerror:. But don’t do that in any code that is at all serious.