Group Group Group Group Group Group Group Group Group

Beginning Table Views · Deleting Multiple Rows | Ray Wenderlich

#1

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

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?

#3

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!

#4

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.

#5

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!