Skip to content

Commit

Permalink
Merge pull request #200 from prabal4546/main
Browse files Browse the repository at this point in the history
Swipe to Delete
  • Loading branch information
twostraws authored Sep 7, 2021
2 parents 52d0a7a + e8d7c0d commit f919552
Showing 1 changed file with 15 additions and 0 deletions.
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()
}
}
}

0 comments on commit f919552

Please sign in to comment.