0
我無法將此代碼的名字和姓氏組合起來,以便將其更新爲tableviewcell。看起來好像它沒有保存名字或姓氏,只是在我輸入新文本時將其替換。我不確定發生了什麼,我確定我在.plist中使用的行號與碼。任何幫助這個或其他的替代品,表示讚賞。iOS Xcode Swift將輸入姓名和姓氏合併爲FullName問題
func textfieldTextWasChanged(newText: String, parentCell: CustomCell) {
let parentCellIndexPath = tblExpandable.indexPathForCell(parentCell)
let currentFullname = cellDescriptors[0][12]["primaryTitle"] as! String
let fullnameParts = currentFullname.componentsSeparatedByString(" ")
var newFullname = ""
if parentCellIndexPath?.row == 13 {
if fullnameParts.count == 2 {
newFullname = "\(newText) \(fullnameParts[1])"
}
else {
newFullname = newText
}
}
else {
newFullname = "\(fullnameParts[0]) \(newText)"
}
cellDescriptors[0][12].setValue(newFullname, forKey: "primaryTitle")
tblExpandable.reloadData()
}