Book Image

Mastering iOS 12 Programming - Third Edition

By : Donny Wals
Book Image

Mastering iOS 12 Programming - Third Edition

By: Donny Wals

Overview of this book

The iOS development environment has significantly matured, and with Apple users spending more money in the App Store, there are plenty of development opportunities for professional iOS developers. However, the journey to mastering iOS development and the new features of iOS 12 is not straightforward. This book will help you make that transition smoothly and easily. With the help of Swift 4.2, you’ll not only learn how to program for iOS 12, but also how to write efficient, readable, and maintainable Swift code that maintains industry best practices. Mastering iOS 12 Programming will help you build real-world applications and reflect the real-world development flow. You will also find a mix of thorough background information and practical examples, teaching you how to start implementing your newly gained knowledge. By the end of this book, you will have got to grips with building iOS applications that harness advanced techniques and make best use of the latest and greatest features available in iOS 12.
Table of Contents (35 chapters)
Title Page
Copyright and Credits
Dedication
Packt Upsell
Contributors
Preface
Index

Preface

Mastering iOS 12 is the third book in the Mastering iOS series that started in 2016 when iOS 10 was released. Since the release of the first version, this book has grown in size to make sure all of the new and interesting bits of are iOS covered and to teach you how to make sure your iOS applications meet Apple's latest standards. You will learn everything you need to know to build great applications that are packed with great features.

This book follows a learn-by-doing style of teaching. Every newly introduced topic in every chapter is accompanied by a sample application that shows you how to put the new theory you read into practice. This means that this book is a very practical guide to becoming an iOS master. In addition to teaching you a lot of Apple's new and existing frameworks, a lot of focus is placed on Apple's own documentation. Since not every single iOS framework can be covered in one book, it is crucial that you train yourself in scanning and understanding Apple's documentation.

It doesn't matter whether you haven't managed to build an app before, or if you're an experienced iOS developer. This book will help you become a better iOS developer, and it will teach you everything new that iOS 12 has to offer. You will step beyond the basics and you will learn everything you need to know to build high-quality iOS applications.

Who this book is for

This book is for developers who have some experience with iOS programming but want to take their skills to the next level by unlocking the full potential of the latest version of iOS with Swift to build impressive applications. It is assumed that you have some basic knowledge of iOS development throughout the book.

What this book covers

Chapter 1, UITableView Touch-up, covers UITableView, which is the core of many iOS applications. Most developers that attempt to learn iOS will start by implementing a table view. This chapter is intended to provide a warm-up for the next chapters while also providing in-depth information about UITableView and its internals.

Chapter 2, A Better Layout with UICollectionView, explores UITableView's super-powered sibling, UICollectionView. This chapter covers implementing a collection view and writing a custom layout object for it.

Chapter 3, Creating a Detail Page, explains that when you build apps, you'll need to make them work on many different screen sizes. This chapter will show you how to use AutoLayout to create beautiful, adaptive layouts.

Chapter 4, Immersing Your Users with Animation, shows how the best apps set themselves apart with beautiful and subtle animations. In this chapter, you will learn the best animation techniques, and to top it off, you'll learn how to create custom transitions between view controllers.

Chapter 5, Understanding the Swift Type System, focuses on the different data types Swift uses, how they relate to each other, and how to decide what type is best for certain use cases.

Chapter 6, Writing Flexible Code with Protocols and Generics, moves on from learning about the type system's basic concrete types; it's also important to learn about abstractions that make your code more flexible, robust, and future-proof. This chapter will show you how you can improve your Swift code with the right abstractions and principles.

Chapter 7, Improving Application Structure, teaches you how to apply the lessons learned from the previous two chapters to improve an app you've already worked on.

Chapter 8, Adding Core Data to Your App, explains that many apps need to store data in a database. This chapter introduces Apple's Core Data framework as a way to include a database for user data in your app.

Chapter 9, Fetching and Displaying Data from the Network, shows you how you can access data and resources over a network connection and display the results to the user.

Chapter 10, Being Proactive with Background Fetch, explains that iOS allows apps to refresh and load data in the background. You will learn how to implement Background Fetch and you will briefly be introduced to Dispatch Groups.

Chapter 11, Syncing Data with CloudKit, covers how to store data in the cloud with CloudKit. It also covers a scenario where CloudKit is used as online storage, while Core Data is used to persist data locally.

Chapter 12, Using Augmented Reality, demonstrates how you can use Apple's groundbreaking ARKit framework to build an augmented reality experience.

Chapter 13, Improving Apps with Location Services, covers several ways that apps can implement location tracking to enhance and improve a user’s experience.

Chapter 14, Making Smarter Apps with CoreML, teaches everything you should know about the CoreML framework. Readers will implement a machine learning model that recognizes dominant objects in a scene. This chapter also covers CreateML to augment existing models with more specific training data.

Chapter 15, Tracking Activity Using HealthKit, explains how to access a user's health information and how you can implement an app that tracks a user's workouts and stores them in the Health app.

Chapter 16, Streamlining Experiences with Siri, shows you how to integrate the SiriKit APIs in your own applications. This enables you to integrate your app deeply into the iOS platform. It also covers the new Siri shortcuts that allow users to quickly perform actions in certain apps.

Chapter 17,Using Media in Your App, explains how to play back audio and video, take photos, and apply interesting filters to images that users take with your app.

Chapter 18, Implementing Rich Notifications, is a walk-through of everything you need to know about providing a great notification experience for your users. It covers both the UI extension and the content extension.

Chapter 19, Instant Information with a Today Extension, shows that developers can add widgets to the Notification Center to disclose quick information to users; this chapter will teach you how.

Chapter 20, Exchanging Data with Drag and Drop, takes you through how to augment an app to allow users to drag contents from your app to other apps and vice versa.

Chapter 21, Improved Discoverability with Spotlight and Universal Links, explores how you can make an iOS index for your app's contents to make it available through the powerful Spotlight search index.

Chapter 22, Extending iMessage, shows how to build a simple sticker pack and app for iMessage.

Chapter 23, Ensuring App Quality with Tests, focuses on testing, which is an often-overlooked aspect of developing an app. You will learn how to set up tests for your application.

Chapter 24, Discovering Bottlenecks with Instruments, explains how to profile your app's performance with instruments. You also learn how to implement and use your own instrument tools.

Chapter 25, Offloading Tasks with Operations and GCD, covers apps that perform increasingly complex tasks. You will learn how to ensure that complex or slow tasks don't freeze your user interface.

Chapter 26, Submitting Your App to the App Store, explains how to distribute your app to beta testers through TestFlight and how to submit your app for review in order to publish it to the App Store.

To get the most out of this book

All sample code in this book was written in Swift 4.2 with Xcode 10.0 on a Mac running macOS Mojave. To follow along with all the examples in this book you must have at least Xcode 10.0 installed on your machine. It is recommended that you also have at least macOS Mojave installed on your Mac because not all code samples are compatible with older versions of macOS.

This book assumes that you are somewhat familiar with Swift and iOS development. If you have no experience with Swift at all, it is recommended that you skim through Apple's Swift manual and go over the basics of iOS development. You don't have to be an expert on iOS development yet, but a solid foundation won't hurt you since the pacing of the book is aimed at somewhat experienced developers.

Download the example code files

You can download the example code files for this book from your account at www.packt.com. If you purchased this book elsewhere, you can visit www.packt.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

  1. Log in or register at www.packt.com.
  2. Select the SUPPORT tab.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box and follow the onscreen instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR/7-Zip for Windows
  • Zipeg/iZip/UnRarX for Mac
  • 7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Mastering-iOS-12-Programming-Third-Edition. In case there's an update to the code, it will be updated on the existing GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Download the color images

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://www.packtpub.com/sites/default/files/downloads/9781789133202_ColorImages.pdf.

Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "Mount the downloaded WebStorm-10*.dmg disk image file as another disk in your system."

A block of code is set as follows:

func doSomething(completionHandler: (Int) -> Void) {
  // perform some actions
  var result = theResultOfSomeAction
  completionHandler(result)
}

Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "Select System info from the Administration panel."

Note

Warnings or important notes appear like this.

Note

Tips and tricks appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: If you have questions about any aspect of this book, mention the book title in the subject of your message and email us at [email protected].

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packt.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Reviews

Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!

For more information about Packt, please visit packt.com.