Group Group Group Group Group Group Group Group Group

Beginning Table Views · Moving Rows | Ray Wenderlich

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.

Thanks!

Hello, I downloaded materials for this lesson, this is your code and project gif with the issue, and it is having the same issue that @ruipasilvsa and @saranyamohan having.

found the solution, implement this in checklistViewController

override func shouldPerformSegue(withIdentifier identifier: String, sender: Any ?) -> Bool {

tableView.isEditing ? false : true

}

3 Likes

Thanks Shum89, it fixes the undesired behaviour.
(Just remove the space between Any and ?) ^^

Faced the same issue where the item would be automatically enter edit mode even when moved.

override func shouldPerformSegue(withIdentifier identifier: String, sender: Any ?) -> Bool { 
tableView.isEditing ? false : true
}

This code solved the issue!

@shum89 @akashlal Thank you for sharing the solution - much appreciated! :]