O'Reilly logo

Swift 3 ObjectOriented Programming - Second Edition by Gastón C. Hillar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required