LoginSignup
6
7

More than 5 years have passed since last update.

Swift: コマンドラインで引数を受け取る方法

Posted at
work-with-args.swift
var args = String[]()

for index in 0..C_ARGC {
    args.append(String.fromCString(C_ARGV[Int(index)]))
}

println(args)
% swift work-with-args.swift && ./work-with-args foo bar baz
[./work-with-args, foo, bar, baz]

コマンドラインからの実行方法はSwiftをコマンドラインから実行 - Qiitaを参考にしました。

6
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
7