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.
Learning iOS Development
A Hands-on Guide to the Fundamentals of iOS Programming
Maurice Sharp
Erica Sadun
Rod Strougo
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.
The publisher offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales, which may include electronic versions and/or custom covers and content particular to your business, training goals, marketing focus, and branding interests. For more information, please contact:
U.S. Corporate and Government Sales
(800) 382-3419
For sales outside the United States, please contact:
International Sales
Visit us on the Web: informit.com/aw
Library of Congress Control Number: 2013938698
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.
ISBN-13: 978-0-321-86296-9
ISBN-10: 0-321-86296-1
Text printed in the United States on recycled paper at R. R. Donnelley in Crawfordsville, Indiana.
First printing: November 2013
Editor-in-Chief
Mark Taub
Senior Acquisitions Editor
Trina MacDonald
Senior Development Editor
Chris Zahn
Managing Editor
Kristy Hart
Senior Project Editors
Betsy Gratner
Jovana Shirley
Copy Editor
Kitty Wilson
Indexer
Tim Wright
Proofreader
Anne Goebel
Technical Reviewers
Gemma Barlow
Mark H. Granoff
Scott Gruby
Marcantonio
Magnarapa
Editorial Assistant
Olivia Basegio
Cover Designer
Chuti Prasertsith
Senior Compositor
Gloria Schurick
To my wife, Lois, and my daughter, Karli. They gave me the
time I needed to work on the book, even though it effectively
meant a second job on top of my day one. You did it with love
and compassion and still had energy for when I could be there.
Maurice
Foreword
Its been an amazing five years since the first edition of the iPhone Developers Cookbook debuted for the new Apple iPhone SDK. Since then, new APIs and new hardware have made the task of keeping on top of iOS development better suited for a team than for an individual. By the time the iOS 5 edition of the Cookbook rolled around, the book was larger than a small baby elephant. We had to publish half of it in electronic form only. It was time for a change.
This year, my publishing team sensibly split the Cookbook material into several manageable print volumes. This volume is Learning iOS Development: A Hands-on Guide to the Fundamentals of iOS Programming. My coauthors, Maurice Sharp and Rod Strougo, moved much of the tutorial material that used to comprise the first several chapters of the Cookbook into its own volume and expanded that material into in-depth tutorials suitable for new iOS developers.
In this book, youll find all the fundamental how-to you need to learn iOS 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.
There are two other volumes in this series as well:
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 offers the recipes you need for working with graphics, touches, and views to create mobile applications.
The Advanced iOS 6 Developers Cookbook focuses on common frameworks such as Store Kit, Game Kit, and Core Location. It helps you build applications that leverage these special-purpose libraries and move beyond the basics. This volume is for those who have a strong grasp of iOS development and are looking for practical how-to information for specialized areas.
Its been a pleasure to work with Maurice and Rod on Learning iOS Development. They are technically sharp, experienced developers, and theyre genuinely nice guys. Its difficult to hand over your tech baby to be cared for by someone else, and these two have put a lot of effort into turning the dream of Learning iOS Development into reality. Maurice, who wrote the bulk of this volume, brings a depth of personal experience and an Apple background to the table.
iOS has evolved hugely since the early days of iPhone, both in terms of APIs and developer tools. Learning iOS Development is for anyone new to the platform, offering a practical, well-explored path for picking up vital skills. From your first meeting with Objective-C to App Store deployment,