开发者

Accessing command line arguments in Objective-C

Is there any complete d开发者_Python百科ocumentation (the interface is present in crt_externs.h) about this functions : _NSGetArgc and _NSGetArgv I can't get any documentation on the apple website about this functions.


If all you need to do is get the command line arguments in Cocoa, you can do:

NSArray *arguments = [[NSProcessInfo processInfo] arguments];


You can also access the commandline arguments using NSUserDefaults as described in the blogposts by Greg Miller or Alex Rozanski.

You basically get an NSUserDefaults instance through a call to [NSUserDefaults standardUserDefaults] and then use messages like boolForKey: or stringForKey: to access the values.

The official Apple documentation can be found here.


As those functions are prefixed with an "_", that's usually a sign that they are private, and not meant to be used by you. If you need to get the command line arguments, a better way to do it would be to look up NSProcessInfo.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜