I recently tried to create a custom UITableViewCell class by adding a slight improved UITextField. I also code in swift 2, and I realized this error by recompiling the project in beta version of Xcode 7. I initialized the array by calling the custom init method.
Heres is my code:
INITIATION METHOD
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
}
The error is displayed on the line:
for character in objectAttributeValues[countOfRun] {
I have no idea what it could be ... Someone can help me.
Thank you very much!
source
share