Connecting the Course List Selection with the Web View

In order to load the course URL in the web view on selection you will need to trigger a call to loadURL(_:) when the table view selection changes.

Knowing what you know of Cocoa, how would you accomplish this? Come up with two or three approaches before reading on.

Got two or three? Here are some that we came up with:

  • Directly couple the two view controllers by adding a reference from CourseListViewController to WebViewController. Call a method on the WebViewController whenever the selected course changes.

    This would be the simplest approach and it would also be effective. But it has a serious disadvantage in the way that it couples the two view controllers directly ...

Get Cocoa Programming for OS X: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.