How do I save files to $(PROJECT_DIR) from objective-c code?
I have code which generates resources which I want to save in a subdirectory of my $(PROJECT_DIR). How do I get the real开发者_Go百科 path from this environment variable in code?
open the projects build settings and add SAVEPATH=@\"$(PROJECT_DIR)\"
to the preprocessor macros.
Then you can get the project directory like this:
NSString *projectDir = SAVEPATH;
I'm not sure if Xcode 3.2.6 has changed the way that ()
are used with environment variables, but I've found that using the following pre-processor macro works for me (@fluchtpunkt's answer gives me a compiler error):
PROJECT_DIR=@\""$PROJECT_DIR"\"
Then I can do:
NSString *savePath = [PROJECT_DIR stringByAppendingPathComponent:@"Save Folder"];
精彩评论