Resources folder path in cocoa app

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?”

  • How do I create a preferences window in Objective-C?
  • What does SEGV_ACCERR mean?
  • replacing self->isa because of Xcode 4.6 deprecation
  • __next_prime symbol undefined
  • Fetched Property in Core Data
  • Generating non-repeating random numbers
  • 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

    Solutions Collect From Internet About “Resources folder path in cocoa app”

    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"];