【发布时间】:2015-06-16 18:25:07
【问题描述】:
我最近试图通过添加一个小的改进 UITextField 来构建一个自定义 UITableViewCell 类。 我也在 swift 2 中编码,我通过在 Xcode 7 beta 中重新编译项目来意识到这个错误。 我通过调用自定义的 init 方法初始化了数组。
这是我的代码:
初始化方法
init(dataObject: [NSManagedObject]!, objectAttributeValues: [String]!,placeholder: String!, segmentedControl: UISegmentedControl?) {
self.dataObject = dataObject
self.Placeholder.text = placeholder
self.objectAttributeValues = objectAttributeValues
if segmentedControl != nil {
self.segmentedControl = segmentedControl!
didHaveSegmentedControl = true
}
}
required init(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
IBACTION EditingChanged
currentInputCount = "\(TextField.text)".characters.count
var indexOfArray: Int = 0
countOfRun = 0
if currentInputCount == 0 {
countOfRun = 0
formerInputCount = 0
editingDidEndForTextField = false
concatenedWord = []
Placeholder.text = ""
}
if !editingDidEndForTextField && currentInputCount > 0 {
while countOfRun < dataObject.count {
if !backspaceWasPressed() {
var arrayOfCharacters: [String] = []
if countOfRun <= dataObject.count - 1 {
for character in objectAttributeValues[countOfRun] {
let string = String(character)
arrayOfCharacters.append(string)
}
}
var convertedStringInFormOfArrayOfStrings: [String] = arrayOfCharacters
if currentInputCount == 1 {
concatenedWord.append(convertedStringInFormOfArrayOfStrings[currentInputCount-1])
}
else if countOfRun > 0 {
if objectAttributeValues[countOfRun].characters.count != concatenedWord[countOfRun].characters.count {
concatenedWord[countOfRun] = concatenedWord[countOfRun] + convertedStringInFormOfArrayOfStrings[currentInputCount-1]
}
}
countOfRun += 1
}
错误出现在一行:
for character in objectAttributeValues[countOfRun] {
我不知道它可能是什么...... 谁能帮帮我。
非常感谢!
【问题讨论】:
标签: ios xcode swift swift2 xcode7