Mastering Swift 4
Fourth Edition
An in-depth and comprehensive guide on modern programming techniques with Swift
Jon Hoffman
BIRMINGHAM - MUMBAI
Mastering Swift 4
Fourth Edition
Copyright 2017 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: June 2015
Second edition: November 2015
Third edition: October 2016
Fourth edition: September 2017
Production reference: 1250917
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-78847-780-2
www.packtpub.com
Credits
Author
Jon Hoffman | Copy Editor
Safis Editing |
Reviewer
Arthur Ariel Sabintsev | Project Coordinator
Ulhas Kambali |
Commissioning Editor
Ashwin Nair | Proofreader
Safis Editing |
Acquisition Editor
Reshma Raman | Indexer
Rekha Nair |
ContentDevelopmentEditor
Vikas Tiwari | Graphics
Abhinash Sahu |
Technical Editor
Subhalaxmi Nadar | Production Coordinator
Melwyn D'sa |
About the Author
Jon Hoffman has over 25 years of experience in the field of information technology. Over these years, Jon has worked in the areas of system administration, network administration, network security, application development, and architecture. Currently, Jon works as a senior software engineer for Syn-Tech Systems.
Jon has developed extensively for the iOS platform since 2008. This includes several apps that he has published in the App Store, apps that he has written for third parties, and numerous enterprise applications. He has also developed mobile applications for the Android and Windows platforms. What really drives Jon is the challenges that the field of information technology provides, and there is nothing more exhilarating to him than overcoming a challenge.
Some of Jon's other interests are spending time with his family, robotic projects, and 3D printing. Jon also really enjoys Tae Kwon Do, where he and his oldest daughter, Kailey, earned their black belts together early in 2014, Kim (his wife), earned her black belt in December 2014, and his youngest daughter, Kara, is currently working toward her black belt.
About the Reviewer
Arthur Ariel Sabintsev is one of the lead iOS engineers at The Washington Post. His mobile engineering career includes working for a U.S. government-funded digital identity startup (ID.me), a Techstars-funded video startup (Shelby.tv), and an award winning mobile development agency (Fueled). He's spent the last 4 years teaching Swift and Objective-C for General Assembly and Betamore. He also maintains over a dozen open source iOS libraries and has made contributions to the Swift language and to the Swift Source Compatibility Suite. Before leaving his PhD program, he was an experimental nuclear physicist who worked underground colliding subatomic and subnuclear particles.
www.PacktPub.com
For support files and downloads related to your book, please visit www.PacktPub.com .
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at service@packtpub.com for more details.
At www.PacktPub.com , you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
https://www.packtpub.com/mapt
Get the most in-demand software skills with Mapt. Mapt gives you full access to all Packt books and video courses, as well as industry-leading tools to help you plan your personal development and advance your career.
Why subscribe?
- Fully searchable across every book published by Packt
- Copy and paste, print, and bookmark content
- On demand and accessible via a web browser
Customer Feedback
Thanks for purchasing this Packt book. At Packt, quality is at the heart of our editorial process. To help us improve, please leave us an honest review on this book's Amazon page at https://www.amazon.com/dp/1788477804.
If you'd like to join our team of regular reviewers, you can email us at customerreviews@packtpub.com. We award our regular reviewers with free eBooks and videos in exchange for their valuable feedback. Help us be relentless in improving our products!
Preface
Swift is a programming language that was first introduced by Apple at the World Wide Developers Conference (WWDC) in 2014. Each year since that initial announcement, Apple has announced a new version of Swift. At the WWDC in 2017, Apple announced Swift 4.
Swift 4 offers some exciting changes, such as Strings, which are once again a collection of Generic subscripts and one-side range operators. In this book, we will look at these and other changes in Swift.
What this book covers
, Taking the First Steps with Swift, introduces you to the the Swift programming language and discusses what inspired Apple to create Swift. We'll also go over the basic syntax of Swift and how to use Playgrounds to experiment and test the Swift code.
, Learning about Variables, Constants, Strings, and Operators, introduces you to variables and constants in Swift and when to use them. We will also look at the most common operators in the Swift language.
, Using Swift Collections and the Tuple Type, explains Swift's array, set, and dictionary collection types and shows examples of how to use them. We'll also show how to use the Tuple type in Swift.
Next page