如何在 Swift 中访问程序参数? [英] How do I access program arguments in Swift?

查看:37
本文介绍了如何在 Swift 中访问程序参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C 和衍生产品的入口点函数有 argcargv(和 envp)参数,但 Swift 没有一个合适的: 顶层代码就是代码,没有参数.

C and derivatives have argc and argv (and envp) parameters to their entry point functions, but Swift doesn't have one proper: top-level code is just code and it doesn't have parameters.

如何在 Swift 程序中访问等效的 argcargv?

How can one access the equivalent of argc and argv in a Swift program?

推荐答案

Process 刚刚重命名为 CommandLine(从 Swift 3.0 8 月 4 日快照开始)

Process was just renamed into CommandLine (since Swift 3.0 August 4 snapshot)

let arguments = CommandLine.arguments

(出于某种原因,更改日志)

这篇关于如何在 Swift 中访问程序参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆