Exploring Swift
With chapters selected by Craig Grummitt
  • August 2018
  • ISBN 9781617296215
  • 94 pages
Exploring Swift
With chapters selected by Craig Grummitt

Swift is more than just a modern replacement for Objective-C. Ever since going open source in 2015, Swift has evolved into a language that is powerful, modern, and expressive. It’s used everywhere from web development to server-side development and cloud-based services! There's a rich, deep world of Swift skills for delivering cleaner, faster code. All you have to do is find out how to use it.

Exploring Swift distils the knowledge of three expert Manning authors, introducing you to how Swift can handle a wide array of unique problems. Hand-picked by iOS developer, Manning author, and mentor Craig Grummitt, this quick-start guide has you exploring objects, modeling data with enums, and solving graph issues, all with just Swift, giving you an understanding of the language in the worlds of data and beyond. When you finish, you'll have a better idea of what you can use Swift for, whether you’re building the next big iOS app, taking it to the server, or even writing serverless functions!

Table of Contents detailed table of contents

Introduction

Swift objects

3 Swift objects

3.1 Classes

3.1.1 Defining a class

3.1.2 Properties

3.1.3 Initializers

3.1.4 Methods

3.1.5 Computed properties

3.1.6 Class inheritance

3.1.7 Protocols

3.2 Structures

3.2.1 Structures vs. classes

3.3 Extensions

3.3.1 Extensions of your type

3.3.2 Extensions of their type

3.3.3 Operator overloading

3.3.4 Generics

3.4 Summary

Modeling data with enums

2 Modeling data with enums

2.1 Enums instead of subclassing

2.1.1 Forming a model for a workout app

2.1.2 Creating a superclass

2.1.3 The downsides of subclassing

2.1.4 Refactoring a data model with enums

2.1.5 Deciding on subclassing or enums

2.1.6 Exercises

2.2 Enums for polymorphism

2.2.1 Compile-time polymorphism

2.3 Or versus and

2.3.1 Modeling data with a struct

2.3.2 Turning a struct into an enum

2.3.3 Deciding between structs and enums

2.4 Enums are algebraic data types

2.4.1 Algebraic data types

2.4.2 Sum types

2.4.3 Product types

2.4.4 Distributing a sum over an enum

2.4.5 Exercise

2.5 A safer use of strings

2.5.1 Dangers of raw values

2.5.2 Matching on Strings

2.5.3 Exercises

2.6 Summary

2.7 Answers

Graph problems

4 Graph problems

4.1 Building a graph framework

4.1.1 A concrete implementation of Edge

4.1.2 A concrete implementation of Graph

4.2 Finding the shortest path

4.2.1 Defining a path

4.2.2 Revisiting breadth-first search (BFS)

4.3 Minimizing the cost of building the network

4.3.1 Workings with weights

4.3.2 Finding the minimum spanning tree

4.4 Finding shortest paths in a weighted graph

4.4.1 Dijkstra’s algorithm

4.5 Real-world applications

4.6 Exercises

index

What's inside

  • Swift Objects from iOS Development with Swift by Craig Grummitt
  • Modeling data with enums from Swift in Depth by Tjeerd in ’t Veen
  • Graph problems from Classic Computer Science Problems in Swift by David Kopec

About the author

Craig Grummitt is a successful developer, instructor, and mentor. Tjeerd in 't Veen is a senior software engineer and architect who builds iOS apps. David Kopec is an assistant professor of computer science and innovation at Champlain College in Burlington, Vermont.

buy

FREE domestic shipping on three or more pBooks