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.

Convert strings to time intervals

Convert strings to time intervals

From the course: iOS Development Tips

Convert strings to time intervals

- [Instructor] In the last tip I showed you how to use UIPicker controllers to make a time interval input. What I didn't show you is how to output that. In this tip I'll show you how to read and convert data from a picker that has a separate delegate. If you download the exercise file you'll have a copy of the project as I left it last week. If you go to TimeComponents you'll see the first problem. This is a delegate actually of a picker. It does not communicate directly with a ViewController. I'm going to set up a delegate for this that has two parameters, the time in a string and a time interval. So I'm going to put right above here a protocol. And I'm going to call it TimeComponentsDelegate, and I'll put a function in here, didSelect. And I'll put timeString, which will be a string and that'll be a string that'll be of the component so we have our time listed as a string. And I also want to do it as a time interval. So I'm going to make that seconds. And that's a TimeInterval…

Contents