How to retrieve the contents of a TEXT FILE stored locally in the documents directory?
From stackoverflow
-
Assuming the text is UTF-8 encoded:
NSData *textFileData = [NSData dataWithContentsOfFile:pathToTextFile]; NSString *textFileString = [NSString stringWithUTF8String:[textFileData bytes]]; -
You can also use this
NSStringclass method (assuming the text is UTF-8):NSString *content = [NSString stringWithContentsOfFile:pathToTextFile encoding:NSUTF8StringEncoding error:&error];errorshould be a pointer to anNSErrorobject.
0 comments:
Post a Comment