我在 Xcode 源代码树中定义了一个名为“MY_SRC_DIR”的路径变量。我想获取这个环境变量的值并将其放入 obj-c 代码中的 NSString 中。例如,
-(NSString*) getSourceDir
{
return @"${MY_SRC_DIR}"; // not the right solution and this is the question
}
From http://rosettacode.org/wiki/Environment_variables#Objective-C http://rosettacode.org/wiki/Environment_variables#Objective-C:
[[NSProcessInfo processInfo] environment]
返回当前环境的 NSDictionary。
例如:
[[[NSProcessInfo processInfo] environment] objectForKey:@"MY_SRC_DIR"]
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)