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);
精彩评论