Ios 在TableView中移动UITableViewCell索引[SWIFT]

Ios 在TableView中移动UITableViewCell索引[SWIFT],ios,uitableview,swift,Ios,Uitableview,Swift,选择UITableViewCell后,我想将其移动到数组的末尾。如何更改UITableViewCell的索引 var tableViewData = ["1", "2","3","4"] ... func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!){ let mySelectedCell:UITableViewCell = tableView.cellForRow

选择UITableViewCell后,我想将其移动到数组的末尾。如何更改UITableViewCell的索引

var tableViewData = ["1", "2","3","4"]
...

func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!){
    let mySelectedCell:UITableViewCell = tableView.cellForRowAtIndexPath(indexPath)

    // Move the cell
    ...
}

谢谢

这应该适用于您的特定示例注意,这假设您的表视图只有一个部分:

// Remove the item from the data array
let item = data.removeAtIndex(indexPath.row)
// Add the item again, at the end of the array
data.append(item)

// Move the corresponding row in the table view to reflect this change
tableView.moveRowAtIndexPath(indexPath, toIndexPath: NSIndexPath(forRow: data.count - 1, inSection: 0))