开发者

Use an external text file to populate a UILabel

开发者 https://www.devze.com 2023-03-13 15:21 出处:网络
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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消