Use an external text file to populate a UILabel
I want to populate a UILabel with a string made from a txt file, I've read many posts 开发者_StackOverflowon here and most talk about it being in the Resources file using [NSBundle], but I want it to come from a an external server, like below, but the string is always null.
NSString *filePath = @"http://mydomain.com/textfile.txt";
NSString *string = [NSString stringWithContentsOfFile:filePath encoding:NSASCIIStringEncoding error:NULL];
NSLog(@"string = %@", string); // is (null)
I think you can parse the filePath to URL and use stringWithContentOfUrl
精彩评论