I'm making a game for iPhone and my game object is in C++ and I save and load user data from that class. I am using a text file and std::ifstream and std::ofstream for reading and writing. During development I've just been dragging the text file from my Supporting Files folder to between the two "" in my code and I get a path which has worked for testing. Now I'd like to finalize that code so that it will work on users' devices.
Is there a way I can get, or hard-code a file path
without using Objective-C, as in
NSString * filePath = [[NSBundle mainBundle] pathForResource:@"UserData"
ofType:@"txt"];
If not, what would be a good way to engineer getting the file path? Can I do it in a way without using Objective-C in my C++ class? The question is really about coding style and design for portability, since the game will be ported to Android devices.
I was reading a little bit about sand-boxing. Should I make efforts to safeguard my file or can I get away without it?
Edit:
I've thought of this, creating a function in the Objective-C view that gets the path and calling that from the C++ class, but then I'd have to have a pointer to the Objective-C class in the C++ class.
Or, have the Objective-C class call a setter function of the c++ class when things start up.
I just haven't done enough of this to know good style.