Book Image

Swift Essentials - Second Edition

By : Alex Blewitt
Book Image

Swift Essentials - Second Edition

By: Alex Blewitt

Overview of this book

Swift was considered one of the biggest innovations last year, and certainly with Swift 2 announced at WWDC in 2015, this segment of the developer space will continue to be hot and dominating. This is a fast-paced guide to provide an overview of Swift programming and then walks you through in detail how to write iOS applications. Progress through chapters on custom views, networking, parsing and build a complete application as a Git repository, all by using Swift as the core language
Table of Contents (17 chapters)
Swift Essentials Second Edition
About the Author
About the Reviewer

Swift and storyboards

So far in this chapter, the storyboard content does not involve any Swift or other programming content—it used the drag and drop capabilities of the storyboard editor. Fortunately, it is easy to integrate Storyboard and Swift using a custom view controller.

Custom view controllers

Each standard view controller has a corresponding superclass (listed in the Scenes and view controllers section previously in this chapter). This can be replaced with a custom subclass, which then has the ability to influence and change what happens in the user interface. To replace the message in the Message Scene, create a new file named MessageViewCotroller.swift with the following content:

import UIKit
class MessageViewController: UIViewController {

Having created this class, it can be associated with the view controller by selecting it in the storyboard and then switching to the identity inspector by navigating to View | Utilities | Show Identity Inspector or pressing Command + Option ...