我正在做一个游乐场来检查swift 2.0,这种情况发生了:
我不知道我是否遗失了什么,或者这是正常还是什么?谢谢。 在swift 1.2中正如预期的那样工作XCode 6.3。 编辑:代码
//: Playground - noun: a place where people can play
import Foundation
var str = "Hello, playground"
let languageType: String = "Swift"
var version = 1.0 //infered
let introduced = 2014 //infered
let isAwesome = true //infered
let π = 3.1415927
let = "dogcow"
let someString = "I appear to be a string"
let pathComponent = "~/Documents/Swift".pathComponents
var s = String("bla vla nla")
for character in "catDog" {
print(character)
}
答案 0 :(得分:1)
String for String在Swift 2中已经改变,为了完成你想要做的事情,你会改用for character in "catDog".characters {...}
一个很好的参考是Nate Cook的swiftdoc.org