From the course: Swift: Delegations and Data Sources
Unlock the full course today
Join today to access over 22,500 courses taught by industry experts or purchase this course individually.
Delegates in iOS storyboards
From the course: Swift: Delegations and Data Sources
Delegates in iOS storyboards
- [Narrator] Delegates in storyboards are not that much different than in code. I'll finish getting the desserts controller working to show you the few differences for a storyboard. Go to dessert view controller and at the very top of the code, above the class add the protocol for dessert view controller delegate. Here I'll add one method: did choose dessert. That has one parameter, dessert of type, order item. In the properties for the dessert view controller I'll declare a property delegate. That will be the type of my protocol. Dessert view controller delegate. Again I'll make it optional, and I'll set it's value to null. Head down to the done button code. We'll get rid of this console so we can see more. And in here, above the pop view controller, add delegate, did choose dessert, and our order item will be dessert. This code will run a function, which I don't know what it does yet, but will have a dessert value when I'm trying to communicate outside the controller. All right, now…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.