Group Group Group Group Group Group Group Group Group

Beginning Table Views · Moving Rows | Ray Wenderlich

This is a companion discussion topic for the original entry at

Hi @bdmoakley, i try omitting setEditing( ) and it still works as expected. Is it compulsory to override this if we’re gonna go on edit mode?

@bdmoakley Can you please help with this when you get a chance? Thank you - much appreciated! :]

Good catch. Overriding the method is not needed in our case. If you want to provide additional behavior when entering edit mode, then you would add the code in that method.

1 Like

@bdmoakley, is the implementation for moving sections the same as moving rows. In the Swift documentation for UITableView, I saw that there is a “moveSection” function. I tried replicating the move row process but after some effort and a lot of googling, I can’t seem to get it right so I am curious if the methodology for implementing the two are the same or different.

I am asking because I think this would be a good user experience for user’s that desire reordering sections along with rows.


Thanks for the heads up. We’ll keep it in mind in the next update of this course.

The index(of:)method call should be replaced by the firstIndex(of:).

Also the moveRowAt method has many other similar methods and the autocompletion one does not always bring to your solution. You could add a note to specify which one we want. If I write “tableviewssourceindexpath” I get it, otherwise with just “moverowat” I don’t.

@bdmoakley Do you have any feedback about this? Thank you - much appreciated! :]

1 Like

Thanks for the feedback!

1 Like

Everything has been working fine up to this point. Not even a yellow flag! :slight_smile: However, when I get the hamburger symbol to move items, I can move the items. However, immediately following the move, it is as though I had clicked on the detail disclosure button and I am taken to the detail view for the item. I thought I could use a “tableView.isEditing” to make the underlying detail disclosure button non-functional. I couldn’t find a way to do that. Thanks for any help with this!

Xcode Beta 11.0 Beta 5

@bdmoakley Can you please help with this when you get a chance? Thank you - much appreciated! :]

Unfortunately, this course doesn’t support the current Xcode beta. That may be a bug. My suggestion is to try the sample project with Xcode 10 and compare against the provide final projects.

Seems like in moveRow(at:to:) “reloadData” method on tableView causes the bug, commenting out the line solved the issue for me.

@denproz Thank you for sharing your solution - much appreciated! :]

How did you manage to do:
“navigationItem.leftBarButtonItem = editButtonItem”
I understood previously when we were using the storyboard and adding a barbuttonitem to the navigation item (when we did the + or when we did Cancel and Add/Done)…but I don’t know how you managed to do the code above.
No where did we declare or instantiate an ‘editButtonItem’. And ‘editButtonItem’ isn’t a case of an enumeration. So what does that line of code even mean?

This may help:

editButtonItem documentation

editButtonItem is a property of UIViewController. When you assign it to a navigation bar, it will display Edit or Done according the state of the controller, and set the state when tapped.

1 Like

@denproz, @shogunkaramazov, in case you comment out reloadData func you will face a bug at the very end of this course. In order to avoid the bug I created a var itemMoved: Bool? = false just after declaring var todoList. It shows wether item was moved by a user in edit mode. The var is switched on just before reloadData by itemMoved = true.
Then I overrode func shouldPerformSegue. It tells segue wether to perform or not. See the algorithm below:
override func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool {
var result = true
if identifier == “EditItemSegue” && itemMoved! {
itemMoved = false
result = false
return result

Hi @bdmoakley
In the edit mode, when I move rows from one place to another, on releasing the click from a row, it gets selected and entering into the edit page. But I go back to the checklist page by clicking cancel everything’s fine(row moved in latest position).

Can you please help with where am I going wrong?

I’m actually having the same issue and I can’t seem to fix it. Did you get to fix this?

This is really hard to diagnose without actually looking at the code. Feel free to email the project files and I’ll take a look.

FYI - I only review project files related to the current tutorial as opposed to personal projects.