最后的替换可以简写成
let index2 = advance(str6, 15)
let index3 = advance(str6, 50)
str.replaceRange(index2..<index3, with: "111111111111")
原来是:str.stringByReplacingCharactersInRange(Range<String.Index>(index2..<index3), withString: "111111111")
let index2 = advance(str6, 15)
let index3 = advance(str6, 50)
str.replaceRange(index2..<index3, with: "111111111111")
原来是:str.stringByReplacingCharactersInRange(Range<String.Index>(index2..<index3), withString: "111111111")
2015-05-02
最赞回答 / 括号扯蛋侠
var str = "Hello, playground"str.characters.countfor c in str.characters{ print(c)}
2015-04-25