<分区>
我只是想使用 for 循环来运行一些代码,但我收到了预期的声明错误。
var index = 0
for( i in 0..< array.count) {
let commonPrefix = array[i].commonPrefixWithString(array[index], options: .CaseInsensitiveSearch)
if (countElements(commonPrefix) == 0 ) {
let string = array[index].uppercased();
let firstCharacter = string[string.startIndex]
let title = "\(firstCharacter)"
let newSection = (index: index, length: i - index, title: title)
sections.append(newSection)
index = i
}
}
帮助