Group Group Group Group Group Group Group Group Group

Beginning Table Views · Segues | Ray Wenderlich


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

Hi! Thanks for the lesson. I think there is a small mistake in a sample code: we don’t need to pop VC twice: in delegate method (CheckListViewController) and button methods (AddItemTableViewController). It may cause an error if CheckListViewController isn’t a root VC.

Yeah, that sounds like a bug. Thanks for the heads up!

Hi,

I don’t really get why you need to access the protocol in the prepare for segue function

Hi, I don’t understand why I do have this error message
"Use of unresolved identifer ‘item’ " item has been declared in func as directed.
I tried also to use the material from the download section ( copy and paste) but still have this issue.

Could someone help me to resolve this mystery ?

thanks

Hey there, looking at your code, I don’t see item being declared in your function. You’ll need to fix your function header to include the item and that will fix the issues.

func addItemViewController(_ controller: AddItemTableViewController, didFinishAdding **item**: CheckListItem)

Hi, I’ll try to help answer this although I’m also doing this tutorial for the first time too! In the last video you created a protocol to handle the cancel/add notifications passing along the data. You then added a variable to AddItemTableViewController called ‘delegate’ that was this type of protocol. Then you put code in AddItemTableViewController to invoke the delegate functions when things were either cancelled or new item added. Then you extended CheckListItemViewController to implement the protocol. Finally we need to somewhere tell the AddItemTableViewController that the delegate we want it to use is THIS CheckListItemViewController which now contains the custom code to respond to the cancel/add item notification. The only way to do that is at the point that CheckListItemViewController is going to segue into AddItemTableViewController. At that point you can get the AddItemTableViewController and set it’s delegate property to be this CheckListItemViewController. There is no way to access that AddItemTableViewController UNTIL the prepare for segue function. If you had tried to set it in another function (like viewDidLoad of CheckListItemViewController) you wouldn’t have had access to the instance of AddItemTableViewController that you’ll later segue to.)

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