O'Reilly logo

Swift Programming: The Big Nerd Ranch Guide by John Gallagher, Matthew Mathias

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

Adding Swift to an Objective-C Project

Now that you have a small Objective-C project working, it is time to add some Swift files. Imagine, for example, that you have an epiphany: It would be far better not to hardcode your contacts as strings in an array. Instead, you could create a Contact type and then display the contacts’ names in the table. You decide to use Swift for your new type because you heard how safe its initialization process is, and you want to take advantage of it.

Add a new Swift file to your project. Click FileNewFile.... In the window that pops up, make sure iOS is selected at the top. Select Swift File under the Source label and click Next (Figure 28.11).

Figure 28.11 Adding a new Swift file

In ...

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