Bronze and Gold


#1

Bronze

override func tableView(tableView: UITableView, titleForDeleteConfirmationButtonForRowAtIndexPath indexPath: NSIndexPath) -> String? {
        return "Remove"
}

Or use this to change some things about the remove button, (like the color). You can use this method to add extra actions. (extra buttons).

override func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? {
        let deleteAction = UITableViewRowAction(style: .Default, title: "Remove") { (action, indexPath) in
            self.tableView(tableView, commitEditingStyle: .Delete, forRowAtIndexPath: indexPath)
        }
        deleteAction.backgroundColor = UIColor.greenColor() // Changing the color of the Remove button.

        return [deleteAction]
}

Gold

override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return itemStore.allItems.count + 1
}

In cellForRowAtIndexPath.

if indexPath.row < itemStore.allItems.count {
	let item = itemStore.allItems[indexPath.row]
	cell.textLabel?.text = item.name
	cell.detailTextLabel?.text = "$\(item.valueInDollars)"
} else {
	cell.textLabel?.text = "No more items!"
	cell.detailTextLabel?.text = ""
}
override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
        return indexPath.row < itemStore.allItems.count ? true : false
}
override func tableView(tableView: UITableView, targetIndexPathForMoveFromRowAtIndexPath sourceIndexPath: NSIndexPath, toProposedIndexPath proposedDestinationIndexPath: NSIndexPath) -> NSIndexPath {
        let storeCount = itemStore.allItems.count
        if proposedDestinationIndexPath.row < storeCount {
            return proposedDestinationIndexPath
        }
        return NSIndexPath(forRow: storeCount - 1, inSection: 0)
}