I have a few .txt files my app accesses and gets data from.
The way I understand it, using my project's copy bundle resources
build phase will correctly install these files into the Apple-mandated开发者_开发问答 directories when the app is run on the user's computer.
Again, as I understand it, this is all I need to do to make the .txt files legal for the Mac Apple Store. Please correct me if I'm wrong.
So, I'm doing the above step. The .txt files are added to the project and to the build step.
Once the app is running, how do I open those files? How do I get the file path?
I'm looking for a standard filepath like: @"~/Library/<app-identifier>/filename.txt>"
Does a list of such special file paths exist?
You should use one of the NSBundle
methods. The most basic is:
NSString *path = [[NSBundle mainBundle] pathForResource:@"filename"
ofType:@"txt"];
Have a look at the NSBundle Class Reference for methods where you can specify subdirectories and how to get other bundles than the main bundle.
精彩评论