Tag: delegates
-
Segue Actions
If you’ve been working with View controllers for a while, you’ve probably dealt with prepareForSegue. In Xcode 11, there’s a new way to handle this that makes a little more sense: Segue actions. Let’s take a look at this feature. If you download the storyboard, you’ll find I set one up for you. It is…
-
Why do we need Delegates in iOS and WatchOS?
About two years ago someone asked me a very good question: Why do we need delegates for UIViewControllers? He thought Swift made things easier, but this delegate stuff seems very complicated. Shouldn’t we be able to send a message or initializer between classes? When I first learned iOS, I’ll admit it took me months to…
-
Using Segues and Delegates for Navigation Controllers in Swift 4.0
[Updated 2/13/2018 to Xcode 9 / Swift 4.0] It should be one of the easiest things we do, and yet for many it is the most confusing. Getting data from one view controller to another as you switch views never seems easy. Segues might be slightly difficult, but delegates to get the information back have…
-
A Swift Tutorial for Working with Classes Part 3: Abstract classes.
In the first tutorial in this series we introduced classes. In the second we did some more advanced manipulations of classes. In both, we discussed the idea of inheritance, which has one final possibility: a class whose only purpose is to define other classes. This is known as an abstract class. Abstract classes are mere…
-
The Swift Swift Tutorial: Why Do We Need Delegates?
[Updated to Swift 2.0/iOS9 SJL 9/28/15] A Note to readers: This post is out of date. Since Swift 3.0, iOS 10 and watchOS 3 have so many changes, I made a new post wth proper syntax, and a lot better illustrations. You can find that here on my site or here on LinkedIn Pulse …
-
The Swift Swift Tutorial: How to Use UITableView in Swift
[Converted to to Swift 2.0/iOS9 9/28/15 SJL] The workhorse control in iOS is the table view. With both a delegate and data source it is powerful, flexible and can get a bit complicated. In this lesson, we will add a table view controller between the Pizza Demo and the Edit Price scenes in our earlier…
-
The Swift Swift Tutorial: Using Delegates and Segues in Swift Part 2 — The Pizza Demo App
In our last post, we went through a very basic framework for segues and delegates in Swift. This time, we will add the segues and delegates to the pizza demo application so we can change the prices in the dictionary for the pizzas. Swift and Xcode is still in beta, and there are quirks I’ll…