1
我只是试图使用for循环来运行某些代码,但我得到了一个Expected声明错误。使用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
}
}
帮助
而在什么行/列? – Evert
定义“sections”在哪里? – Evert
* newSection *是什么类型? – dfd