Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Swift 4 Programming Cookbook

You're reading from  Swift 4 Programming Cookbook

Product type Book
Published in Sep 2017
Publisher Packt
ISBN-13 9781786460899
Pages 384 pages
Edition 1st Edition
Languages
Toc

Table of Contents (9) Chapters close

Preface 1. Swift Building Blocks 2. Building on the Building Blocks 3. Data Wrangling with Swift Control Flow 4. Generics, Operators, and Nested Types 5. Beyond the Standard Library 6. Swift Playgrounds 7. Server-Side Swift 8. Performance and Responsiveness in Swift

Introduction

Since Apple announced the Swift programming language at WWDC 2014, it has gone on to become one of the fastest growing programming language. TIOBE is a company that measures software quality and publishes a ranking index of programming language usage. At the time of writing, Swift ranks the 12th most popular language on this index and has overtaken Objective-C (visit http://www.tiobe.com/tiobe_index).

Swift is a modern, general purpose programming language that focuses on type safety, and an expressive and concise syntax. Seen as a replacement for the aging Objective-C, its use among Mac and iOS developers has skyrocketed, ensuring its place as the future of development on Apple's platforms.

While occupying this niche would alone ensure Swift's place as a useful and important programming language. Apple's decision to open source Swift's runtime and compiler have allowed Swift's influence to extend beyond Apple's ecosystem, giving it the potential to be used across all platforms and for any scenario.

Since open sourcing the Swift toolchain, Apple has provided support for running your Swift code on Linux. In the later chapters, we will investigate using a Swift server to execute your code. In addition, the release of the Swift Playgrounds iPad app, which happened alongside iOS 10, turns your tablet into a lightweight Integrated Development Environment (IDE). However, the simplest way to get up and running with Swift is still on Mac and with Apple's Xcode IDE. Therefore, this book will assume that this is also the development environment of the reader. Xcode also provides a perfect way to explore the structure and syntax of the Swift standard library, foundation, and any other framework available for iOS or Mac development in the form of its Playgrounds feature.

An Swift Playgrounds is a simplified environment for executing Swift code. For our purposes, Playgrounds provide an ideal way to create, execute, debug, and understand the recipes contained in this book. As such, it will also be assumed that the reader is using an Xcode Playground to implement the recipes contained in this book, unless otherwise stated.

Swift 3, released in 2016, presented a major step forward in standardizing the language syntax and, as a result, migrating code written in Swift 2 to Swift 3 was not always an easy task. Swift 4, by contrast, has been designed to be source compatible with Swift 3; therefore, the task of migrating between Swift 3 and Swift 4 should be minimal. Swift 4 has been available in a prerelease form since the beta release of Xcode 9, and will be finalized with the release of Xcode 9 and iOS 11. This book will use Swift 4 throughout, and differences from Swift 3 will be highlighted.

In this chapter, we will look at the building blocks of the Swift language, examining the syntax and functionality of the basic Swift constructs that everything else is based on.

All the code for this chapter can be found in GitHub repository at https://github.com/SwiftProgrammingCookbook/SwiftBuildingBlocks.

You have been reading a chapter from
Swift 4 Programming Cookbook
Published in: Sep 2017 Publisher: Packt ISBN-13: 9781786460899
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at AU $19.99/month. Cancel anytime}