Book Image

iOS Programming Cookbook

Book Image

iOS Programming Cookbook

Overview of this book

Do you want to understand all the facets of iOS programming and build complex iOS apps? Then you have come to the right place. This problem-solution guide will help you to eliminate expensive learning curves and focus on specific issues to make you proficient at tasks and the speed-up time involved. Beginning with some advanced UI components such as Stack Views and UICollectionView, you will gradually move on to building an interface efficiently. You will work through adding gesture recognizer and touch elements on table cells for custom actions. You will work with the Photos framework to access and manipulate photos. You will then prepare your app for multitasking and write responsive and highly efficient apps. Next, you will integrate maps and core location services while making your app more secure through various encryption methods. Finally, you will dive deep into the advanced techniques of implementing notifications while working with memory management and optimizing the performance of your apps. By the end of the book, you will master most of the latest iOS 10 frameworks.
Table of Contents (22 chapters)
iOS Programming Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Preface

iOS is evolving every year to provide a better experience for its users. Not only the system, but also the hardware of iPhone and iPad devices, which require a powerful system like the iOS to utilize the features of hardware is evolving. The latest release of iOS now comes with great features to give iOS developers the chance to develop mobile apps with new ideas or enhance the experience of current apps with new features. The book tries to cover the new features of iOS and let iOS developers get their hands dirty by writing sample demos with the features to understand how they work. The book is not meant to be a theory book, which talks about technical things, such as new APIs, or about any specific topic. The book is a cookbook that takes you within minutes to the point and guides you to build a simple demo to understand what is going on using examples, which is the best way to make things stick in your mind.

What this book covers

Chapter 1, Swift Programming Language, is a simple revision of Swift 3 and an explanation of the most important topics in Swift.

Chapter 2, The Essentials, covers the most commonly used UI components, such as UIView, gestures, stack views, and so on.

Chapter 3, Integrating with Messages App, talks about one of the hottest features in iOS—how to integrate with the iOS Messages app to add your own stickers or develop extensions.

Chapter 4, Working with Interface Builder, provides tips and tricks while dealing with interface builders, such as storyboards and XIB files. Get your hands dirty with Autolayout and size classes and know how to work with them.

Chapter 5, Working with UITableView, covers one of the most important components in iOS that all iOS developers should be aware of.

Chapter 6, Animations and Graphics, gives your apps a better look by teaching you how to animate views and draw simple shapes.

Chapter 7, Multimedia, helps you to deal with audio and video in iOS. It provides information about how to use filters thanks to the Core Image framework.

Chapter 8, Concurrency, overcomes the fear of using concurrency in iOS by helping you understand how to use dispatch queues and NSOperationQueues with simple examples.

Chapter 9, Location Services, covers the most commonly used operations in location services, such as getting a user's location, adding pins, navigation, and geofencing.

Chapter 10, Security and Encryption, discusses how to secure your app and protect your user’s sensitive information using Touch ID for authentication and saving data in a device's Keychain.

Chapter 11, Networking, covers how to establish networking in an iOS app to retrieve data and parse it.

Chapter 12, Persisting Data with Core Data, takes you through the workings of Core Data to persist data and perform CRUD (creation, reading, updating, and deletion) operations.

Chapter 13, Notifications, helps you overcome the hassle of dealing with push notification and setup and gets you started with configuring your project and server to send and receive notifications.

Chapter 14, App Search, looks at making your app content searchable from Spotlight and Safari suggestions.

Chapter 15, Optimizing Performance, showcases how to measure the performance of your app and how to enhance it.

What you need for this book

Any Mac hardware-running macOS system, such as MacBook Pro, MacBook Air, Mac Mini, iMac, or Mac Pro.

Some chapters require testing on an iOS device with iOS 10.0 or later version.

The software requirements are Xcode 8.1 or later, which requires a Mac running macOS 10.11.5 or later, and iOS Simulator 10.0 or later.

Who this book is for

If you are an iOS developer on a quest to develop your perfect iOS app, then this book is for you. It would also prove to be a valuable resource for those who want to get up and running with iOS development through a clear, practical approach. In order to unleash the full potential of this book, basic Swift programming knowledge is necessary.

Sections

In this book, you will find several headings that appear frequently (Getting ready, How to do it, How it works, There's more, and See also).

To give clear instructions on how to complete a recipe, we use these sections as follows:

Getting ready

This section tells you what to expect in the recipe, and describes how to set up any software or any preliminary settings required for the recipe.

How to do it…

This section contains the steps required to follow the recipe.

How it works…

This section usually consists of a detailed explanation of what happened in the previous section.

There's more…

This section consists of additional information about the recipe in order to make the reader more knowledgeable about the recipe.

See also

This section provides helpful links to other useful information for the recipe.

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: " The sort function gives us another flexibility by which you can provide a closure that returns the comparison result between any two items in the list to determine which should come first in the list."

A block of code is set as follows:

{ (parameters) ->returnType in 
   // block of code goes here 
}

Any command-line input or output is written as follows:

cd path_to_directory

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Under Relationship Segue, click on view controllers to make this view controller part of the view controllers list on the tab bar controller."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book-what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail [email protected], and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors .

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

You can download the code files by following these steps:

  1. Log in or register to our website using your e-mail address and password.

  2. Hover the mouse pointer on the SUPPORT tab at the top.

  3. Click on Code Downloads & Errata.

  4. Enter the name of the book in the Search box.

  5. Select the book for which you're looking to download the code files.

  6. Choose from the drop-down menu where you purchased this book from.

  7. Click on Code Download.

You can also download the code files by clicking on the Code Files button on the book's webpage at the Packt Publishing website. This page can be accessed by entering the book's name in the Search box. Please note that you need to be logged in to your Packt account.

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/iOS-Programming-Cookbook. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/ . Check them out!

Downloading the color images of this book 

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from https://www.packtpub.com/sites/default/files/downloads/iOSProgrammingCookbook_ColorImages.pdf.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books-maybe a mistake in the text or the code-we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at [email protected] with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at [email protected], and we will do our best to address the problem.