Group Group Group Group Group Group Group Group Group

Beginning Table Views · Deleting Multiple Rows | Ray Wenderlich


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/5995-beginning-table-views/lessons/48

Hello, at around 3:40, on line 28 of, when we are creating an array of checklisteItems, why is there a “()” after the declaration and initialization of the array?

The parenthesis is really the constructor. Essentially, this:

var numbers =  [Int]()

Is the equivalent of this:

var numbers = Array<Int>()

By omitting the parenthesis, you are just indicating the type without calling the constructor:

var numbers = Array<Int>

So that’s why we add the parenthesis after the type. I hope that helps!

Dear, @bdmoakley

How can I resign editing session when I press (+) or when I change to a different view? Right now, it seems like I am still in the edit mode when i go back and forth from a add Item view to a main checkListItemView.

Hey there, what you can do is call setEditing() in your prepare(for segue:). Set it to false at the beginning of the segue and that will reset the table before the new view controller is pushed on the stack. Good luck!

Dear sir,

I got the following error where the indexPath did not have row member.

What are the workaround to this?
Appreciate any help.

For some reason, Xcode thinks you have an array of ints as opposed to an array of indexpaths. It’s a little hard see why that’s happening from this vantage. Feel free to email the project to brian@razeware.com and I’ll take a look.

Did you end up solving this? I have the exact same issues

@hans123dev

Looks like @mkiara called indexPathForSelectedRow on the tableView instead of indexPathsForSelectedRows. The first one will only return a single index path not an array of index paths.
Most likely that’s why you have that error as well.

Hope that helps!

Thanks. Yes I did end up finding that mistake eventually.

Hi everyone,
Brain, thank you for the course! :smiley: It explains plenty of concepts and features. It is quite hard for me, but the length of videos allows to rewatch it easily. Thank you very much for your explanations!

I have a question. How can I make the Delete Button enable only when a user is editing the Checklists?