Reputation: 482
I am working on Mac OS X app which using some c files, and i have a configuration file i add it to the app resources.
My question is "What is the relative path of resources folder?"
I tried
"[MyAppName].app/Contents/Resources/config.cfg"
and it works fine only when I run my app from xCode, otherwise it's doesn't work!
I thought the app starts from "MacOS" folder, so i used this path: "../Resources/config.cfg"
but it also didn't work :(
any help please
Upvotes: 5
Views: 4613
Reputation: 39847
Using relative paths is asking for trouble. Fortunately Cocoa will give you an absolute path:
NSBundle *myBundle = [NSBundle mainBundle];
NSString *absPath= [myBundle pathForResource:@"config" ofType:@"cfg"];
Upvotes: 11