IBAction 周围的单引号 [英] Single quotes around IBAction

查看:29
本文介绍了IBAction 周围的单引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个按钮来创建一个 IBAction,那个按钮是继续.但是,在附加操作时,我希望继续使用小写字母.出于某种原因,当我附加操作时,它被单引号括起来.为什么会这样?

I have a button to create an IBAction, and that button is Continue. However, when attaching the action I want to have a lower case continue. For some reason when I attach the action it is surrounded by single quotes. Why is this the case?

@IBAction func `continue`() {
  //
}

推荐答案

continue 是一个 swift 关键字(与许多其他编程语言一样),因此不能用于变量或动作名称,除非用反引号包裹起来.

continue is a swift keyword (along with many other programming languages) and as such cannot be used for variable's or action names without being wrapped in backtick quotes.

编译器用反引号将其包装起来,以免将其计算为关键字 continue

The compiler wraps it in backtick quotes as to not compute it as the keyword continue

Apple 文档

这篇关于IBAction 周围的单引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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