anticyclope
anticyclope

Reputation: 1587

How to access argc/argv in iOS application?

I have to run my iOS app in simulator, providing some additional info on launch.

However, I can't find a way to access argc/argv in my app. I thought I can find these somewhere in UIApplication, but I can't. Then I've checked - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions, but launchOptions was nil.

Is there a way to get an access to command-line arguments in iOS application?

Upvotes: 0

Views: 1635

Answers (2)

Raptor
Raptor

Reputation: 54212

the launch option is used as follow:

launchOptions

A dictionary indicating the reason the application was launched (if any). The contents of this dictionary may be empty in situations where the user launched the application directly. See “Launch Options Keys” in UIApplication Class Reference for descriptions of these keys.

See UIApplicationDelegate documentation

Upvotes: 0

user244343
user244343

Reputation:

Save values in either a plist which you read every startup, or in the NSUserDefaults dictionary from a previous run, which you access at startup.

If it must be external only, and argument-based only, set the arguments array from NSProcessInfo:

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

Upvotes: 6

Related Questions