ebook img

Pro iPhone Development with Swift 4: Design and Manage Top Quality Apps PDF

457 Pages·2018·8.43 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Pro iPhone Development with Swift 4: Design and Manage Top Quality Apps

Pro iPhone Development with Swift 4 Design and Manage Top Quality Apps — Molly Maskrey Wallace Wang Pro iPhone Development with Swift 4 Design and Manage Top Quality Apps Molly Maskrey Wallace Wang Pro iPhone Development with Swift 4: Design and Manage Top Quality Apps Molly Maskrey Wallace Wang Parker, Colorado, USA San Diego, California, USA ISBN-13 (pbk): 978-1-4842-3380-1 ISBN-13 (electronic): 978-1-4842-3381-8 https://doi.org/10.1007/978-1-4842-3381-8 Library of Congress Control Number: 2018932359 Copyright © 2018 by Molly Maskrey and Wallace Wang This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed. Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights. While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein. Cover image designed by Freepik Managing Director: Welmoed Spahr Editorial Director: Todd Green Acquisitions Editor: Aaron Black Development Editor: James Markham Technical Reviewer: Bruce Wade Coordinating Editor: Jessica Vakili Copy Editor: Karen Jameson Compositor: SPi Global Indexer: SPi Global Artist: SPi Global Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer- sbm.com, or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation. For information on translations, please e-mail [email protected], or visit http://www.apress.com/ rights-permissions. Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales web page at http://www.apress.com/bulk-sales. Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub via the book's product page, located at www.apress.com/978-1-4842-3380-1. For more detailed information, please visit http://www.apress.com/source-code. Printed on acid-free paper This book is dedicated to everyone who has an idea for an app but didn’t know what to do first or how to get started. First, believe in your idea. Second, trust that you have intelligence to achieve your dream even if you don’t know how you’ll get there. Third, keep learning and improving your skills all the time. Fourth, stay focused. Success will come one day as long as you persist and never give up on yourself. Table of Contents About the Authors ����������������������������������������������������������������������������������������������������xi About the Technical Reviewer �������������������������������������������������������������������������������xiii Chapter 1: Multithreaded Programming Using Grand Central Dispatch �������������������1 Creating the SlowWorker Application3 Threading Basics 7 Units of Work 8 GCD: Low-Level Queuing 9 Improving SlowWorker 10 Background Processing 17 Application Life Cycle 19 State-Change Notifications 20 Creating State Lab 22 Exploring Execution States 23 Using Execution State Changes 26 Handling the Inactive State 27 Handling the Background State 33 Saving State When Entering the Background 37 Summary43 Chapter 2: Simple Games Using SpriteKit ��������������������������������������������������������������45 Creating the TextShooter App 46 Initial Scene Customization 51 Player Movement 57 Creating Your Enemies63 Putting Enemies in the Scene 65 Start Shooting 67 v Table of ConTenTs Attacking Enemies with Physics 73 Finishing Levels 74 Customizing Collisions77 Spicing Things Up with Particles 83 Putting Particles into the Scene 87 Ending the Game 89 Create a StartScene92 Adding Sound Effects 95 Making the Game a Little Harder: Force Fields 96 Summary100 Chapter 3: Taps, Touches, and Gestures ���������������������������������������������������������������103 Multitouch Terminology 104 The Responder Chain 105 Responding to Events 105 Forwarding an Event: Keeping the Responder Chain Alive 107 The Multitouch Architecture 108 The Four Touch Notification Methods 108 Creating the TouchExplorer Application 110 Creating the Swipes Application 116 Using Touch Events to Detect Swipes 116 Automatic Gesture Recognition 120 Implementing Multiple Swipes 122 Detecting Multiple Taps 125 Detecting Pinch and Rotation Gestures 131 Summary137 Chapter 4: Determining Location ��������������������������������������������������������������������������139 The Location Manager 140 Setting the Desired Accuracy 140 Setting the Distance Filter 141 Getting Permission to Use Location Services 142 vi Table of ConTenTs Starting the Location Manager 142 Using the Location Manager Wisely 142 The Location Manager Delegate 143 Getting Location Updates 143 Getting Latitude and Longitude Using CLLocation 143 Error Notifications147 Creating the WhereAmI Application147 Using Location Manager Updates 155 Visualizing Your Movement on a Map 159 Changing Location Service Permissions 164 Summary165 Chapter 5: Device Orientation and Motion ������������������������������������������������������������167 Accelerometer Physics 167 Rotation Detection Using the Gyroscope 169 Core Motion and the Motion Manager 169 Creating the MotionMonitor Application 170 Proactive Motion Access 176 Gyroscope and Attitude Results 179 Accelerometer Results 180 Detecting Shakes 182 Baked-In Shaking 182 The Shake and Break Application 183 Accelerometer as a Directional Controller 188 The Ball Application 188 Calculating Ball Movement 195 Summary198 Chapter 6: Using the Camera and Accessing Photos ��������������������������������������������199 Using the Image Picker and UIImagePickerController200 Using the Image Picker Controller 200 Implementing the Image Picker Controller Delegate 203 vii Table of ConTenTs Creating the Camera Interface 205 Privacy Options 208 Implementing the Camera View Controller 210 Summary215 Chapter 7: Translating Apps Using Localization ���������������������������������������������������217 Localization Architecture218 Strings Files 219 The Strings File220 The Localized String Function 221 Creating the LocalizeMe App 222 Localizing the Project 230 Localizing the Storyboard 234 Generating and Localizing a Strings File 242 Localizing the App Display Name 249 Adding Another Localization 252 Summary253 Chapter 8: Using Machine Learning ����������������������������������������������������������������������255 Understanding Machine Learning 256 Finding a Core ML Model 257 Image Recognition 258 Creating the Image Recognition Application259 Identifying Objects from the Camera 269 Analyzing an Image 275 Summary283 Chapter 9: Using Facial and Text Recognition ������������������������������������������������������285 Recognizing Faces in Pictures 286 Highlighting Faces in an Image 293 Highlighting Parts of a Face in an Image 301 viii Table of ConTenTs Recognizing Text in an Image 309 Summary315 Chapter 10: Using 3D Touch ����������������������������������������������������������������������������������317 Understanding 3D Touch 318 Detecting 3D Touch Availability 321 Detecting Pressure 323 Creating Home Screen Quick Actions 325 Responding to Quick Action Items 329 Adding Dynamic Home Screen Quick Actions 333 Adding Peeking, Popping, and Previewing 339 Summary346 Chapter 11: Using Speech �������������������������������������������������������������������������������������347 Converting Speech to Text 347 Recognizing Spoken Commands356 Turning Text to Speech 358 Summary362 Chapter 12: Understanding SiriKit ������������������������������������������������������������������������363 How SiriKit Works 364 Defining How Siri Interacts with the User 368 Understanding the IntentHandlerswift File 371 Understanding the ExtensionUI Folder 375 Creating a Payment App with Siri 381 Summary386 Chapter 13: Understanding ARKit �������������������������������������������������������������������������389 How ARKit Works 389 Drawing Augmented Reality Objects 397 Resetting the World Origin 399 ix Table of ConTenTs Drawing Custom Shapes 404 Modifying the Appearance of Shapes 407 Summary418 Chapter 14: Interacting with Augmented Reality �������������������������������������������������419 Storing and Accessing Graphic Assets 420 Working with Touch Gestures 423 Detecting a Horizontal Plane 428 Modifying an Image 433 Creating Virtual Objects 435 Summary446 Index ���������������������������������������������������������������������������������������������������������������������447 x

Description:
Acquire and master the information required to take you to the next level beyond basic iPhone development using Swift. In this follow up work to the best selling Beginning iPhone Development with Swift, you’ll learn how to improve your apps by managing the performance of your programs using paral
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.