iOS 12 Programming
for Beginners
Third Edition
An introductory guide to iOS app development with Swift 4.2 and Xcode 10
Craig Clayton
BIRMINGHAM - MUMBAI
iOS 12 Programming for BeginnersThird Edition
Copyright 2018 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 or its dealers and distributors, will be held liable for any damages caused or alleged to have been 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.
Commissioning Editor: Amarabha Banerjee
Acquisition Editor: Larissa Pinto
Content Development Editor: Flavian Vaz
Technical Editor: Akhil Nair
Copy Editor: Safis Editing
Project Coordinator: Kinjal Bari
Proofreader: Safis Editing
Indexer: Rekha Nair
Graphics: Alishon Mendonsa
Production Coordinator: Jyoti Chauhan
First published: October 2016
Second edition: October 2017
Third edition: December 2018
Production reference: 1201218
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-78934-866-8
www.packtpub.com
mapt.io
Mapt is an online digital library that gives you full access to over 5,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website.
Why subscribe?
Spend less time learning and more time coding with practical eBooks and videos from over 4,000 industry professionals
Improve your learning with Skill Plans built especially for you
Get a free eBook or video every month
Mapt is fully searchable
Copy and paste, print, and bookmark content
Packt.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.packt.com and, as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at customercare@packtpub.com for more details.
At www.packt.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.
Contributors
About the author
Craig Clayton is a self-taught, senior iOS engineer at Adept Mobile, specializing in building mobile experiences for NBA and NFL teams. He also volunteered as the organizer of the Suncoast iOS meetup group in the Tampa/St. Petersburg area for three years, preparing presentations and hands-on talks for this group and other groups in the community. He has also launched Cocoa Academy online, which specializes in bringing a diverse list of iOS courses, ranging from building apps to games for all programming levels, to the market.
About the reviewer
Kevin Munc (@muncman) is a programming veteran with 20+ years' experience in a variety of areas, ranging from mainframes to mobile, from web to blockchain, and from enterprise to startup. Along the way, he's reviewed books on Objective-C, watchOS, RFP, UIAutomation, SpriteKit, JavaFX, and Vim.
I would like to thank all of the people who have helped me sharpen my reviewing skills over the years. I'm also grateful for the ongoing support of my family as I continue to seek to grow as a developer.
Packt is searching for authors like you
If you're interested in becoming an author for Packt, please visit authors.packtpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea.
Preface
In this book, we will build a restaurant reservation app called Let's Eat. We will start the book off by exploring Xcode, our programming environment, which is also known as the Interface Development Environment ( IDE ). Next, you will start learning the foundations of Swift, the programming language used in iOS apps. Once we are comfortable with the basics of Swift, we will dig deeper to build a more solid foundation.
Once we have a solid foundation of using Swift, we will start creating the visual aspects of our Let's Eat app. During this process, we will work with storyboards and connect our app's structure together using segues. With our UI complete, we will go over the different ways in which we can display data. To display our data in a grid, we will use Collection Views, and to display our data in a list, we will use Table Views.
We will also look at how to add basic and custom annotations on to a map. Finally, it's time to get real data; we will look at what an Application Programming Interface ( API ) is and how we can get actual restaurant data into our Collection Views, Table Views, and Map.
We now have a complete app, but how about adding some bells and whistles? The first place where we can add a feature will be the restaurant detail page, where we can add restaurant reviews. Here, users will be able to take or choose a picture and apply a filter to their picture. They will also be able to give the restaurant a rating as well as a review. When they are done, we will save this data using Core Data.
Since we built our app to work on both iPhone and iPad, we should add the ability to make our app support iPad multitasking. Doing this will allow our app to be open alongside another app at the same time.
If we want to be able to send our reservation to a friend, we can create a custom UI for iMessages, which will send them the details for the reservation along with the app it came from. The one thing missing from our app is the ability to notify the user with a custom notification to alert when they have an upcoming reservation.
Finally, let's create quick access by using SiriKit and Siri to request money and send reservations. Now that we have added some bells and whistles, let's get this app to our friends using TestFlight, and finally get it into the App Store.
Who this book is for
Next page