Search code examples
xcodeswiftibaction

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

Solution

  • 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