大刘的 iOS 自学笔记

Swift关键字标识符

2022-06-30  本文已影响0人  大刘

https://docs.swift.org/swift-book/ReferenceManual/LexicalStructure.html

To use a reserved word as an identifier, put a backtick (`) before and after it. For example, class is not a valid identifier, but `class` is valid. The backticks aren’t considered part of the identifier; `x` and x have the same meaning.

example:

let `switch`: UISwitch = UISwitch()
`switch`.isOn = false
`switch`.addTarget(self, action: #selector(switchClick), for: .touchUpInside)
self.navigationItem.rightBarButtonItem = UIBarButtonItem(customView: `switch`)
上一篇下一篇

猜你喜欢

热点阅读