I have a dynamic tableView as below, which shows names of an array according to indexpath.row
. And in each cell I have a button that changes the name which is as a deletage to the cell as in the code below. When I load the table assume the rows load as below:
Name1
Name2
Name3
Name4
Name5
Name6
Name7
Name8
And then I click the button and change Name4 to NewName for example. It is changed when the button is clicked but when you scroll in the table, when it comes to the indexpath.row
of Name4 again (where indexpath.row==3
in this case), NewName changes back to Name4. How can I stop the the table to load everytime when the indexpath.row
is changing? Or how can I find another solution to this problem?
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell:NamesCell = tableView.dequeueReusableCellWithIdentifier("Cell") as! NamesCell
cell.NameCell1003 = self
cell.nameLbl.text = self.resultsNameArray[indexPath.row]
return cell
}
func NameCell1003(cell: NamesCell)
{
cell.nameLbl.text= "NewName"
}