Implementing the delegate of a table view
When the user selects a to-do item in the list of items, the details of the to-do item should be shown in a dedicated view. We will implement the actual navigation between the different views of the app in Chapter 11, Easy Navigation with Coordinators. In this section, we will implement the required code in ToDoItemsListViewController
.
Follow these steps to prepare ToDoItemsListViewController
for navigation to the detail view:
- Let's assume we already have a delegate that will provide a method the view controller can call. Add the following test method to
ToDoItemsListViewControllerTests
:// ToDoItemsListViewControllerTests.swift func test_didSelectCellAt_shouldCallDelegate() throws { let delegateMock = ToDoItemsListViewControllerProtocolMock() }
Xcode tells us that it cannot find the ToDoItemsListViewControllerProtocolMock
type. This type is meant to be a mock object for the real delegate...