I'm writing a command line app using Swift but I'm not sure how to get access to the arguments passed in. In C/Obj-c it seems relatively painless but if I try:
argv[0]
I get an error: Use of unresolved identifier 'argv'
There are two ways to do this:
C_ARGC and C_ARGV. They are analogous to the argc and argv you'd see in a main() function.CommandLine.arguments array will contain all of the arguments to the process. (In Swift 2, CommandLine was called Process)If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With