Interacting with an object-oriented data repository through Picker View

Now, we have to add code to the ViewController class in the ViewController.swift source file to make the class conform to two additional protocols: UIPickerViewDataSource and UIPickerViewDelegate. The conformance to the UIPickerViewDataSource protocol allows us to use the class as a data source for the UIPickerView class that represents the Picker View component. The conformance to the UIPickerViewDelegate protocol allows us to handle the events raised by the UIPickerView class.

The following lines show the new code for the ViewController class. The code file for the sample is included in the swift_3_oop_chapter_08_09 folder.

 class ViewController: UIViewController, UIPickerViewDelegate, ...

Get Swift 3 ObjectOriented Programming - Second Edition 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.