Single quotes around IBAction

坚强是说给别人听的谎言 提交于 2019-12-04 06:44:31

问题


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`() {
  //
}

回答1:


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.

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

Apple Doc



来源:https://stackoverflow.com/questions/35869902/single-quotes-around-ibaction

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!