Q:

Mac OSX: how to get content of a text file located somewhere on disk?

I found some posts explaining how to get the content of a text file included in the project bundle. For example here: Reading Text File from XCode Bundle
My question is: once I have the NSString describing the path to my txt file (for example pathString = @"/Users/username/Documents/theFile.txt"), how can I get its content in a string ?
Thanks !

A:

I think you just want this:
NSString *contents = [NSString stringWithContentsOfFile:fullpath encoding:NSUTF8StringEncoding error:nil];

Note that there are quite a few related questions on StackOverflow with usage examples etc - just search for "stringWithContentsOfFile".

