开发者

reading arabic text from a txt file in iphone

开发者 https://www.devze.com 2023-01-28 05:11 出处:网络
I am working on app where I need to display arabic text from a text file. I am using foll开发者_C百科owing code:

I am working on app where I need to display arabic text from a text file. I am using foll开发者_C百科owing code:

NSString *fileContents = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
NSArray *lines = [fileContents componentsSeparatedByString:@"\n"];
NSLog(@"%@",[lines objectAtIndex:0]);

I get about 60 records in this array lines. But when I try to print the data it does not print anything.


If the file starts with a newline, the first element in lines will be just an empty string. Try printing out the whole array instead, just to verify that your code is working as intended:

 NSLog(@"%@", lines);
0

精彩评论

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