Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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...

like image 698
iOS Avatar asked Oct 31 '25 04:10

iOS


1 Answers

Use NSString's stringWithContentsOfFile: method.

NSString *fileContents = [NSString stringWithContentsOfFile:@"some/file.txt"];
like image 99
Jacob Relkin Avatar answered Nov 01 '25 17:11

Jacob Relkin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!