I am new to both Cocoa programming and Xcode. I am wondering how I can setenv (or set environment variable) using MainMenu.nib (or .xib) file. I have someone else's code in the main function like this:
[NSApplication sharedApplication];
[NSBundle loadNibNamed:@"MainMenu" owner: NSApp];
After the second line, it can get an environment variable:
if (!getenv("R_HOME")) {
fprintf(stderr, "R_HOME is not set.\n");
return -1;
}
I want to know how one can construct a nib(or xib) file, e.g., MainMenu.xib, in Xcode 3's latest version so that it can be used to setenv. One thing that I did was to code setenv without using a nib file:
setenv("R_HOME", "/Library/Frameworks/R.framework/Resources", 1)
But, this did not work when I execute the Cocoa GUI programming by double clicking the xxx.app although that worked when I execute the program's command line version. So, it seems like that I need a way to set environment variables when a Mac GUI application is launched. I have seen other ways of setting environment variables, but I want to know how one can set environment variables using nib (or xib) files, and by loading it using NSBundle's loadNibNamed method.