How to achieve swipe right to complete (Todo List)

I'm working on a todo list app, and now I can use these code to achieve swipe left to delete

func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? {
    let delete = UITableViewRowAction(style: .Normal, title: "Delete") { action, index in
        print("Delete button tapped")
    delete.backgroundColor = UIColor.redColor()
    return [delete]

And I think I searched the WHOLE internet but none of those solutions can do the swipe right job and work fine on me at the same time. I'm using swift 2.0, Xcode 7 beta 5.

Anyone done this before?


It think this project can help you further...

SBGestureTableView: Swift UITableView subclass that supports swiping rows ala Mailbox and long press to move rows.

If you don't want to use this class. You can see in there source code, you first need to figure out if the user is swiping from left-to-right or right-to-left. And go from there.

Use commit editing style

 func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {

    let thisTask = fetchedResultsController.objectAtIndexPath(indexPath) as! TaskModel

    if thisTask.completed ==  true {thisTask.completed = false}
    else {thisTask.completed = true}
    (UIApplication.sharedApplication().delegate as! AppDelegate).saveContext()

I'm using CoreData to store my information, and one of the things I'm storing is wether it's completed or not, when a use swipes right on a tableview it changes the completed to true, and I have two sections, one for uncompleted tasks and one for completed

Need Your Help

Xcode UIProgressBar does not increment

iphone objective-c ios cocoa-touch uiprogressview

I am trying to increment progress bar and show percentage on a label. However, both remains without changes when "incrementaProgres" function is called. IBOutlets are properly linked on xib and also

Why is CharInSet faster than Case statement?

delphi delphi-2009 case-statement

I'm perplexed. At CodeRage today, Marco Cantu said that CharInSet was slow and I should try a Case statement instead. I did so in my parser and then checked with AQTime what the speedup was. I foun...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.