Swift Capitalization 大写
示例
类型和协议
类型和协议名称应以大写字母开头。
例:
protocol Collection {}
struct String {}
class UIView {}
struct Int {}
enum Color {}其他一切...
变量,常量,函数和枚举大小写应以小写字母开头。
例:
let greeting = "Hello"
let height = 42.0
enum Color {
case red
case green
case blue
}
func print(_ string: String) {
...
}骆驼香烟盒:
所有命名都应使用适当的驼峰式大小写。类型/协议名称的大写驼峰大写,其他所有内容的小写驼峰。
上驼壳:
protocol IteratorType { ... }下骆驼盒:
let inputView = ...
缩略语
除非经常使用缩写,否则应避免使用缩写(例如URL,ID)。如果使用缩写,则所有字母的大小写均应相同。
例:
let userID: UserID = ... let urlString: URLString = ...