最近在回答StackOverflow的问题时,发现performSelector方法在Swift被去掉,Apple的注释是这个方法被去掉是因为不安全: NOTE The performSelector: method and related selector-invoking methods are not imported in Swift because they are inherently unsafe. 如果在Swift调用这个方法会编译出错: 'performSelector' is…
5.枚举与结构体: 不必给枚举成员提供一个值.如果我们想要为枚举成员提供一个值(raw value),我们可以用字符串,字符,整型或浮点数类型. 1 2 3 4 5 6 7 enum CompassPoint { case North case South case East case West } var directionToHead = CompassPoint.West 结构体 Struct在Swift中和类有许多相同的地方,可以定义属性,方法,初始化方法,可通过extensio…