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 Core iOS Developers Cookbook
Fifth Edition
Erica Sadun
Rich Wardwell
Upper Saddle River, NJ Boston Indianapolis San Francisco
New York 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 authors 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: 2013953064
Copyright 2014 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, One Lake Street, Upper Saddle River, New Jersey 07458, or you may fax your request to (201) 236-3290.
AirPlay, AirPort, AirPrint, AirTunes, App Store, Apple, the Apple logo, Apple TV, Aqua, Bonjour, the Bonjour logo, Cocoa, Cocoa Touch, Cover Flow, Dashcode, Finder, FireWire, iMac, Instruments, Interface Builder, iOS, iPad, iPhone, iPod, iPod touch, iTunes, the iTunes logo, Leopard, Mac, Mac logo, Macintosh, Multi-Touch, Objective-C, Quartz, QuickTime, QuickTime logo, Safari, Snow Leopard, Spotlight, 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.
ISBN-13: 978-0-321-94810-6
ISBN-10: 0-321-94810-6
Text printed in the United States on recycled paper at RR Donnelley in Crawfordsville, Indiana.
First printing: March 2014
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:
Lisa Stumpf
Proofreader:
Anne Goebel
Technical Reviewers:
Collin Ruffenach Mike Shields Ashley Ward
Editorial Assistant:
Olivia Basegio
Cover Designer:
Chuti Prasertsith
Senior Compositor:
Gloria Schurick
Erica Sadun
I dedicate this book with love to my husband, Alberto,
who has put up with too many gadgets and too
many SDKs over the years while remaining both
kind and patient at the end of the day.
Rich Wardwell
I dedicate this book to my wife, Julie, who was relegated
to single-parent status during this endeavor,
and my children, Davis and Anne, who never stopped
asking me to play with them even after countless refusals.
Preface
Welcome to a new Core iOS Developers Cookbook!
With iOS 7, Apple introduced the most significant changes to its mobile operating system since its inception. This cookbook is here to help you get started developing for the latest exciting release. This revision introduces all the new features and visual paradigms announced at the latest Worldwide Developers Conference (WWDC), showing you how to incorporate them into your applications.
For this edition, the publishing team has split the cookbook material into manageable print volumes. This book, The Core iOS Developers Cookbook, provides solutions for the heart of day-to-day development. It covers all the classes you need for creating iOS applications using standard APIs and interface elements. It provides recipes you need for working with graphics, touches, and views to create mobile applications.
And theres Learning iOS Development: A Hands-on Guide to the Fundamentals of iOS Programming, which covers much of the tutorial material that used to comprise the first several chapters of the cookbook. There youll find all the fundamental how-to you need to learn iOS 7 development from the ground up. From Objective-C to Xcode, debugging to deployment, Learning iOS Development teaches you how to get started with Apples development tool suite.
As in the past, you can find sample code at GitHub. Youll find the repository for this Cookbook at https://github.com/erica/iOS-7-Cookbook, all of it refreshed for iOS 7 after WWDC 2013.
If you have suggestions, bug fixes, corrections, or anything else youd like to contribute to a future edition, please contact us at . We thank you all in advance. We appreciate all your feedback, which helps make this a better, stronger book.
Erica Sadun and Rich Wardwell, January 2014