Swift 4 Programming Cookbook
50 task-oriented recipes to make you productive with Swift 4
Keith Moon
BIRMINGHAM - MUMBAI
Swift 4 Programming Cookbook
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: September 2017
Production reference: 1260917
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-78646-089-9
www.packtpub.com
Credits
Author Keith Moon | Copy Editor Shaila Kusanale |
Reviewer Giordano Scalzo | Project Coordinator Ulhas Kambali |
Commissioning Editor Ashwin Nair | Proofreader Safis Editing |
Acquisition Editor Larissa Pinto | Indexer Mariammal Chettiyar |
ContentDevelopmentEditor Onkar Wani | Graphics Abhinash Sahu |
Technical Editor Akhil Nair | Production Coordinator Shraddha Falebhai |
About the Author
Keith Moon is an award-winning iOS developer, author, and speaker based in London. He has worked with some of the biggest companies in the world to create engaging and personal mobile experiences. Keith has been developing in Swift since its release, working on projects both fully Swift, and mixed Swift and Objective-C. Keith has been invited to speak about Swift development in conferences from Moscow to Minsk and London.
I would like to thank my amazing and supportive wife, Alissa. Without her support and patience, this book would not have been possible.
About the Reviewer
Giordano Scalzo is a developer with 20 years of programming experience, since the days of the ZXSpectrum.
He has worked in C++, Java, .NET, Ruby, Python, and in a ton of other languages that he has forgotten the names of.
After years of backend development, over the past five years, Giordano has developed extensively for iOS, releasing more than 20 apps--apps that he wrote for clients, enterprise applications, or on his own.
Currently he is a contractor in London, where through his company Effective Code Ltd, http://effectivecode.co.uk, he delivers code for iOS aiming at quality and reliability.
In his spare time, when he is not crafting retro game clones for iOS, he writes his thoughts on http://giordanoscalzo.com.
Id like to thank my better half Valentina, who lovingly supports me in everything I do; without you, none of this would have been possible.
Thanks to my bright future, Mattia and Luca, for giving me lots of smiles and hugs when I needed them.
Finally, my gratitude goes to my mum and my dad, who gave me curiosity and the support to follow my passions, which began one day when they bought me a ZXSpectrum.
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/1786460890. If you'd like to join our team of regular reviewers, you can e-mail 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
Since Apple announced the Swift programming language at WWDC 2014, it has gone on to become one of the fastest growing programming languages. Swift is modern, open source, and easy to use, and therefore Swift's usefulness can extend beyond Apple's ecosystem, giving it the potential to be used across all platforms and for any scenario.
Swift 4 represents the latest version of this exciting new programming language, giving you the tools to build performant and responsive apps, with safe and clean code.
This book will guide you through Swift's features, building up your knowledge and toolset layer by layer, so you can use Swift to build the next great app or service.
You will be given useful, easy-to-follow recipes for using Swift to accomplish real-world tasks. Each recipe only uses concepts previously covered in the book, so you will never feel lost.
Learn what makes Swift one of the fastest growing and most exciting programming languages available today.
What this book covers
,Swift Building Blocks , introduces you to the basic building blocks of Swift 4, its syntax, and the functionalities of basic Swift constructs. Also, this chapter will introduce you to Apples Xcode 9 IDE and Swift Playgrounds, which provide an ideal way to create, execute, debug, and understand the recipes contained in this book, thus setting you up to initiate the development process. In this chapter, learn to write your first Swift program and understand the various basic elements of the Swift language.
Next page