初学Swift,感觉好多原来可以使用的语法,如今要么报警告要么干脆不能使用了。
println("")//已经不能使用了
重新命名为
print("")
写下面代码的时候,会报两个警告:
for var mm = 0; mm < 10; mm++ {
print("mm is: \(mm)")
}
第一个警告: '++'is deprecated:it will be removed in Swift 3 第二个警告:C-style for statement is deprecated and will be removed in a future version of Swift
第一个警告:++ 和 --将要在Swift3中废弃;可以使用 += 1替代; 第二个警告:C语言风格的声明将在Swift的未来版本废弃和移除。
so,这样的代码尽量不要写了,这里它会提醒你修改为如下代码:
for mm in 0 ..< 10 {
print("mm is: \(mm)")
}
输出结果:
mm is: 0
mm is: 1
mm is: 2
mm is: 3
mm is: 4
mm is: 5
mm is: 6
mm is: 7
mm is: 8
mm is: 9
下面这种写法已经不能使用
for (index, value) in enumerate(studentList) {
print("Item \(index + 1 ) : \(value)")
}
修改为:
for (index, value) in studentList_.enumerate() {
print("Item \(index + 1) : \(value)")
}