Introduction to SDK Development IN ACTION Revised edition of iPhone in Action Brandon Trebitowski Christopher Allen Shannon Appelcline MANNING Praise for iPhone in Action …iPhone in Action is another smash hit by Manning Publications Whether you are a novice programmer or an advanced programmer new to the iPhone platform, you are going to finish this book feeling ready to take on the world —Panah Rad, iPhoneAppsFinder.com If I were teaching a class on the basics of developing for Apple’s new mobile platform, I would definitely use this as the textbook iPhone in Action is a complete primer to iPhone development —Victor Agreda, Jr., The Unofficial Apple Weblog (TUAW) well-suited for existing programmers who want comprehensive coverage of the iPhone platform, the development of webapps, and the key concepts in developing native apps with the SDK along with examples —Peter Cooper, Mobile Orchard …excels at providing detailed, organized, and clear information on the development particularities of the iPhone iPhone in Action is the must-have book for developers looking to enter the realm of iPhone development —Cody Overcash, Founder, ModMyi.com This book is invaluable for beginners because it shows all the possibilities for both web and SDK and it introduces all the key topics—something no other single title does Experts will want this title too for the detailed web development topics —Mark Johnson, reader There is no other iPhone title that has such great coverage of both web and SDK topics under one roof, providing a well-rounded developer education —Vladimir Pasman, Cocoacast.com Download from Wow! eBook Download from Wow! eBook iPhone and iPad in Action INTRODUCTION TO SDK DEVELOPMENT BRANDON TREBITOWSKI CHRISTOPHER ALLEN SHANNON APPELCLINE Revised Edition of iPhone in Action MANNING Greenwich (74° w long.) Download from Wow! eBook For online information and ordering of this and other Manning books, please visit www.manning.com The publisher offers discounts on this book when ordered in quantity For more information, please contact Special Sales Department Manning Publications Co 180 Broad St Suite 1323 Stamford, CT 06901 Email: orders@manning.com ©2011 by Manning Publications Co All rights reserved No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps Recognizing the importance of preserving what has been written, it is Manning’s policy to have the books we publish printed on acid-free paper, and we exert our best efforts to that end Recognizing also our responsibility to conserve the resources of our planet, Manning books are printed on paper that is at least 15 percent recycled and processed without the use of elemental chlorine Manning Publications Co 180 Broad St Suite 1323 Stamford, CT 06901 Development editor: Copyeditor: Proofreader: Typesetter: Cover designer: Katharine Osborne Tiffany Taylor Katie Tennant Dottie Marsico Marija Tudor ISBN 978-1-935182-58-0 Printed in the United States of America 10 – MAL – 15 14 13 12 11 10 Download from Wow! eBook INDEX Webimage App Delegate 54 webView:didFailLoadWithError: 278–279 webView:shouldStartLoadWithRequest: navigationType: 278 webViewDidFinishLoad 278, 280 webViewDidStartLoad 278 willRotateToInterfaceOrientation:duration: 77 window 90 adding view or view controller to 44 as a property 41 introduction 28 key 44 and event response 88 visible 44 Window-Based Application 50–51 template 114 Windows Mobile chat client 317 Wireless Application Protocol Wireless Markup Language wireless network connectivity 5–6 WML See Wireless Markup Language word, drawing, in Quartz 260–261 WPStore creating 347–355 delivering content 354 displaying products 350 handling errors 354 header file 347 initialization 348 preparing for purchase 352 processing a transaction 352 recording a transaction 354 requesting product information 349 selecting a product 350 Store Kit framework, adding 347 transaction history 349 writeToFile:atomically: 154 writeToFile:atomically:encoding:error 155 X x, y, z properties 191 Xcdatamodel 181 Xcode adding frameworks 49 alternate templates 50 and IBOutlet / IBAction 56 automatic migration of build target 376 compiling in 38 configuring, to convert iPhone app to iPad 376–377 creating a new class 45–49 debugging 279 delegate class file name 40 editing window 51 environment 37–38 introduction 4, 15, 36–38 main project window 37 Organizer 52 project, file types 38 resizing views 75 setting up a view controller 72 templates 54 tricks 51 using to access SDK documentation 14 XHTML 280 XML Core Location example 287–289 element 282 error 282 example, RSS reader 282–287 parsing 280–289 reporting end of 282 reporting unrecoverable error 282 reading from files 281 text file, reading 283 Y YouTube interface Z zoomEnabled 332 Download from Wow! eBook 407 iPHONE DEVELOPMENT iPhone and iPad IN ACTION SEE INSERT Trebitowski Allen Appelcline T his hands-on tutorial will help you master iPhone/iPad development using the native iPhone SDK It guides you from setting up dev tools like Xcode and Interface Builder, through coding your first app, all the way to selling in the App Store Using many examples, the book covers core features like accelerometers, GPS, the Address Book, and much more Along the way, you’ll learn to leverage your iPhone skills to build attractive iPad apps This is a revised and expanded edition of the original iPhone in Action “Everything you need to know about these devices of the future!” —Berndt Hamboeck, pmOne “Apple should make this its official iPhone and iPad development book.” —Jason Jung, Rockwell What’s Inside Full coverage of the iPhone SDK In-app purchasing with Store Kit Audio and recording Core Data, Core Location, Game Kit, Map Kit And much more! No previous iPhone or iPad know-how needed Familiarity with C, Cocoa, or Objective-C helps but is not required Brandon Trebitowski is a professional mobile developer with ELC Technologies and founder of iCodeBlog.com Christopher Allen is the host of iphonewebdev.com and an organizer of iPhoneDevCamp Shannon Appelcline is a writer, technologist, and game developer Christopher and Shannon wrote iPhone in Action For online access to the authors and a free ebook for owners of this book, go to manning.com/iPhoneandiPadinAction MANNING $39.99 / Can $49.99 [INCLUDING eBOOK] “Gets you up to speed and developing in a snap.” —Clint Tredway, Developed It “Don’t launch Xcode without it.” —Ted Neward Neward & Associates “Exactly what iNeed for iPhone development.” —Christopher Haupt Webvanta.com