Search code examples
iphoneobjective-cnsfilemanager

How to read a file in iPhone?


I am trying to read a .txt file from my documents directory in the form of NSString. Any idea how to read the file into NSString?

Thank you...


Solution

  • Use NSString's stringWithContentsOfFile: method.

    NSString *fileContents = [NSString stringWithContentsOfFile:@"some/file.txt"];