Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Unwrap/Activities/Challenges/ChallengesDataSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,19 @@ class ChallengesDataSource: NSObject, UITableViewDataSource {
return cell
}
}
/// Swipe to delete
func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
if indexPath.section == 1 && User.current.dailyChallenges.count > 0{
return true
}else{
return false
}
}
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
if editingStyle == .delete{
User.current.dailyChallenges.remove(at: indexPath.row)
tableView.reloadData()
User.current.save()
}
}
}