Group Group Group Group Group Group Group Group Group

Beginning Table Views · Challenge: Refactor Protocol | Ray Wenderlich

#1

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

Hello @bdmoakley,
I’m starting to get the hang of protocols, but there is one thing I am not understanding with the ones we made in this course (thus far)

All our protocol methods are passing the ItemDetailViewController back to the CheckListViewController. I do not understand why we are passing the whole controller? I understand passing the ChecklistItem, as we make use of these to update the UITableView. However, as far as I can see, we never actually do anything with this ‘controller’ parameter

I tested deleting this parameter/argument from the protocols and methods, and everything works fine.

I apologize if I’m jumping the gun and we make use of this in a few lessons.

#3

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

#4

Often times, we’ll pass back a controller to make any additional alterations to it (if we need to). In our case, we’re just dismissing the controller but there may be a situation where you may need to do some clean-up operations or getting additional data from it. By passing back the controller, we have access to it. But, if we don’t need it, we can just disregard it.

#5

Hello @bdmoakley

Everytime I’m refactoring the file gets deleted instead.
-> I make sure name is highlighted -> control klik -> refactor -> rename -> rename to new name -> click refactor -> everywhere it’s renamed but file itself is red and deleted.
Do you know why?
Xcode version 10.1

#6

That sounds like a bug. Not sure what is going on. Honestly, I’ve found Xcode’s refactoring tools to be really twitchy overall. Sometimes the work. Sometimes they don’t. I would download the latest version of xcode and see how it behaves.