About This eBook
ePUB is an open, industry-standard format for eBooks. However, support of ePUB and its many features varies across reading devices and applications. Use your device or app settings to customize the presentation to your liking. Settings that you can customize often include font, font size, single or double column, landscape or portrait mode, and figures that you can click or tap to enlarge. For additional information about the settings and features on your reading device or app, visit the device manufacturers Web site.
Many titles include programming code or configuration examples. To optimize the presentation of these elements, view the eBook in single-column, landscape mode and adjust the font size to the smallest setting. In addition to presenting code and configurations in the reflowable text format, we have included images of the code that mimic the presentation found in the print book; therefore, where the reflowable format may compromise the presentation of the code listing, you will see a Click here to view code image link. Click the link to view the print-fidelity code image. To return to the previous page viewed, click the Back button on your device or app.
The Gourmet
iOS Developers
Cookbook
Even More Recipes for Better
iOS App Development
Erica Sadun
New York Boston Indianapolis San Francisco
Toronto Montreal London Munich Paris Madrid
Cape Town Sydney Tokyo Singapore Mexico City
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals.
The Gourmet iOS Developers Cookbook: Even More Recipes for Better iOS App Development is an independent publication and has not been authorized, sponsored, or otherwise approved by Apple Inc.
Apple, the Apple logo, Apple TV, Apple Watch, Cocoa, Cocoa Touch, eMac, FaceTime, Finder, iBook, iBooks, iCal, Instruments, iPad, iPad Air, iPad mini, iPhone, iPhoto, iTunes, the iTunes logo, iWork, Keychain, Launchpad, Lightning, LocalTalk, Mac, the Mac logo, MacApp, MacBook, MacBook Air, MacBook Pro, MacDNS, Macintosh, Mac OS, Mac Pro, MacTCP, the Made for iPad logo, the Made for iPhone logo, the Made for iPod logo, Metal, the Metal logo, the Monaco computer font, Multi-Touch, the New York computer font, Objective-C, OpenCL, OS X, Passbook, Pixlet, PowerBook, Power Mac, Quartz, QuickDraw, QuickTime, the QuickTime logo, Retina, Safari, the Sand computer font, Shake, Siri, the Skia computer font, Swift, the Swift Logo, the Textile computer font, Touch ID, TrueType, WebObjects, WebScript, and Xcode are trademarks of Apple, Inc., registered in the United States and other countries. OpenGL and the logo are registered trademarks of Silicon Graphics, Inc. The YouTube logo is a trademark of Google, Inc. Intel, Intel Core, and Xeon are trademarks of Intel Corp. in the United States and other countries.
The author and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein.
For information about buying this title in bulk quantities, or for special sales opportunities (which may include electronic versions; custom cover designs; and content particular to your business, training goals, marketing focus, or branding interests), please contact our corporate sales department at or (800) 382-3419.
For government sales inquiries, please contact .
For questions about sales outside the U.S., please contact .
Visit us on the Web: informit.com/aw
Library of Congress Control Number: 2015935369
Copyright 2015 Pearson Education, Inc.
All rights reserved. Printed in the United States of America. This publication is protected by copyright, and permission must be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. To obtain permission to use material from this work, please submit a written request to Pearson Education, Inc., Permissions Department, 200 Old Tappan Road, Old Tappan, New Jersey 07675, or you may fax your request to (201) 236-3290.
ISBN-13: 978-0-13-408622-4
ISBN-10: 0-13-408622-8
Text printed in the United States on recycled paper at RR Donnelley in Crawfordsville, Indiana.
First printing: May 2015
Editor-in-Chief
Mark Taub
Senior Acquisitions Editor
Trina MacDonald
Senior Development Editor
Chris Zahn
Managing Editor
Kristy Hart
Senior Project Editor
Betsy Gratner
Copy Editor
Kitty Wilson
Indexer
Tim Wright
Proofreader
Sarah Kearns
Technical Reviewers
Mark Granoff
Mike Greiner
Rich Wardwell
Editorial Assistant
Olivia Basegio
Cover Designer
Chuti Prasertsith
Compositor
Nonie Ratcliff
Dedicated with great affection to Chris Zahn:
editor, enabler, and wonderful person.
Preface
Developers can never have too many useful ideas to draw from, and this latest entry in the bestselling Cookbook series is filled with delicious possibilities. The Gourmet iOS Developers Cookbook offers a curated selection of programming recipes to inspire your everyday iOS programming efforts. This volume serves up a new banquet of turnkey solutions for projects big and small. It offers a fresh collection of versatile solutions that promise to add spice to your code.
The goal here is simple. Each chapter should enable you to walk away with fresh ideas and master techniques off the beaten track. Whether youre reading about new takes on old technologies or completely fresh APIs, heres hoping youll say, Hey, I didnt know you could do that! or Thats really cool.
The Gourmet iOS Developers Cookbook offers a deep dive into the nonobvious. Its chapters cover techniques and technologies that skew away from the common and enable you to explore new development cuisines. Its not a book for those just learning how to cook apps. It offers tasty recipes for the iOS enthusiast who wants to builds fragrant, delicious, and exotic routines.
How This Book Is Organized
This book offers practical iOS development recipes. Heres a rundown of what youll find in this books chapters:
This chapter explores advances that have made their way into AVFoundation over the past few years and shows how you can integrate these features into your own applications. In this chapter, youll read about speech generation, barcode recognition (which enables you to leverage the device camera to recognize a wide range of barcode styles), and application of modern language features to AVFoundation movie creation.