From the course: iOS Development Tips

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Protocols and time pickers

Protocols and time pickers

From the course: iOS Development Tips

Protocols and time pickers

- While there is the dateComponents picker, sometimes, you want a picker that gives time intervals. Let me show you how to set one up, and also discuss some good uses of protocols, beyond self and delegates. If you download the exercise file, you'll see I set up a project with two pickers, and set outlets for them. You'll see that I set up two ViewControllers... Here is in the storyboard... And you can see I got two ViewControllers, ViewController and SecondViewController here as well, and I have a third file here called TimeComponents. If you're familiar with UI picker views, you know they use a delegate and DataSource to set the components and return values. Usually, you set the delegate and DataSource to self, and then put the code inside each ViewController. However, that means you set the component values in each view controller. I want for my project to have hours, minutes, and seconds on every picker. Instead of writing the code for that several times, I'll make a separate…

Contents