非常感谢刘宇波老师,跟着您的课程边听边写,共写了2478行代码,一步一步排错并结合Swift4语法修正,基本对Swift语法精通了,再次感谢!
2017-09-26
协议是Swift的核心,POP比OOP更能方便的遵守设计模式的诸多模式,尤其是避免上帝类这种工程地雷。
编程要多用组合少用继承,针对接口而非行为编程,OC很难做到,但Swift则可以很轻松的实现
编程要多用组合少用继承,针对接口而非行为编程,OC很难做到,但Swift则可以很轻松的实现
2017-09-25
class Parrot:Bird, Pet {
override required init(name: String) { //感觉override在前更好,因为定义时父类在前,协议在后
super.init(name: name + " " + name)
}
override required init(name: String) { //感觉override在前更好,因为定义时父类在前,协议在后
super.init(name: name + " " + name)
}
2017-09-25
Swift 中循环里添加步长改为:
for i in stride(from: 0, to: 10, by: 2) { //to为开区间,through为闭区间
print("Stride 2")
}
for i in stride(from: 0, to: 10, by: 2) { //to为开区间,through为闭区间
print("Stride 2")
}
2017-09-24
swift3 需要将inout放到参数类型前面
func +=( left: inout Vector3, right: Vector3){
left = left + right
}
func +=( left: inout Vector3, right: Vector3){
left = left + right
}
2017-09-12