Checklists App - ConfigureCheckmarkForCell Method

Hello,

I have a question about the ConfigureCheckmarkForCell Method that is described in the checklists tutorial:
(at the time of posting this I have just reached the ‘Arrays’ part of the tutorial)

This method is called by the tableView(cellForRowAtIndexPath) method. This method returns a cell, and passes the cell to the ConfigureCheckmark method. I understand that swift is pass-by-value, and not reference, unless you use the inout keyword. Since the inout keyword is not used, how is the cell that the tableView(cellForRowAtIndexPath) method returns, modified?

Another somewhat related question: the tableView(didSelectRowAtIndexPath) method does not return a cell. It modifies a cell given by the cellForRowAtIndexPath method, so does this method return a value by reference?

Essentially, I am having trouble understanding how manipulating the local copies of the cells is being reflected in the view controller. Thanks!

Swift has value types (structs and enums) and reference types (classes). UITableViewCell is a class; it’s a reference type.

I see, makes perfect sense. and every time an element on the screen is updated (for example, a cell checkmark is turned off or on), does the system know to automatically refresh the screen? Thank you!

Yes, if you’re changing something in response to a “didSelectRowAtIndexPath”, i.e. a tap from the user, iOS will redraw the screen.

(If you’re changing something not in response to a tap then you have to tell the table view to redraw. This is covered later on in the iOS Apprentice.)

Great, that makes sense. Thank you very much