Iphone SDK Development Building Iphone Applications

Iphone SDK Development Building Iphone Applications

Prepared exclusively for Rodney Pearson Beta Book Agile publishing for agile developers The book you’re reading is still under development. As part of our Beta book program, we’re releasing this copy well before we normally would. That way you’ll be able to get this content a couple of months before it’s available in finished form, and we’ll get feedback to make the book even better. The idea is that everyone wins! Be warned. The book has not had a full technical edit, so it will con- tain errors. It has not been copyedited, so it will be full of typos and other weirdness. And there’s been no effort spent doing layout, so you’ll find bad page breaks, over-long lines with little black rectan- gles, incorrect hyphenations, and all the other ugly things that you wouldn’t expect to see in a finished book. We can’t be held liable if you use this book to try to create a spiffy application and you somehow end up with a strangely shaped farm implement instead. Despite all this, we think you’ll enjoy it! Throughout this process you’ll be able to download updated PDFs from your account on http://pragprog.com. When the book is finally ready, you’ll get the final version (and subsequent updates) from the same address. In the meantime, we’d appreciate you sending us your feedback on this book at http://pragprog.com/titles/amiphd/errata, or by using the links at the bottom of each page. Thank you for being part of the Pragmatic community! Dave & Andy Prepared exclusively for Rodney Pearson iPhone SDK Development Building iPhone Applications Chris Adamson Bill Dudney with Marcel Molina The Pragmatic Bookshelf Raleigh, North Carolina Dallas, Texas Prepared exclusively for Rodney Pearson Many of the designations used by manufacturers and sellers to distinguish their prod- ucts are claimed as trademarks. Where those designations appear in this book, and The Pragmatic Programmers, LLC was aware of a trademark claim, the designations have been printed in initial capital letters or in all capitals. The Pragmatic Starter Kit, The Pragmatic Programmer, Pragmatic Programming, Pragmatic Bookshelf and the linking g device are trademarks of The Pragmatic Programmers, LLC. Every precaution was taken in the preparation of this book. However, the publisher assumes no responsibility for errors or omissions, or for damages that may result from the use of information (including program listings) contained herein. Our Pragmatic courses, workshops, and other products can help you and your team create better software and have more fun. For more information, as well as the latest Pragmatic titles, please visit us at http://www.pragprog.com Copyright © 2008 Chris Adamson, Bill Dudney, and Marcel Molina. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmit- ted, in any form, or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior consent of the publisher. Printed in the United States of America. ISBN-10: 1-934356-25-5 ISBN-13: 978-1-934356-25-8 Printed on acid-free paper. B12.0 printing, April 14, 2009 Version: 2009-4-14 Prepared exclusively for Rodney Pearson Contents Changes in the Beta Releases 10 Beta 12—April 14 .......................... 10 Beta 11—March 2 .......................... 10 Beta 10—January 30 ........................ 11 Beta 9—January 16 ........................ 11 Beta 8—December 19 ........................ 11 Beta 7—December 3 ........................ 12 Beta 6—November 21 ........................ 12 Beta 5—November 14 ........................ 12 Beta 4—October 24 ......................... 13 Beta 3—October 9 .......................... 14 Beta 2—October 3 .......................... 14 1 Hello iPhone 15 1.1 Gearing up .......................... 15 1.2 Create the Hello iPhone Project .............. 17 1.3 Creating a simple Interface ................ 19 1.4 Rotating the Text—adjusting the UI ........... 22 1.5 Rotating the Text—adjusting the code .......... 23 1.6 Code Navigation ....................... 24 1.7 Running your app on your iPhone ............ 25 2 iPhone Development Fundamentals 27 2.1 The iPhone Software Architecture ............. 28 2.2 Coding in Objective-C .................... 28 2.3 Working with Xcode and Interface Builder ........ 30 2.4 Anatomy of your iPhone application ........... 40 2.5 Customizing behavior with delegation .......... 42 2.6 Managing Application Memory .............. 45 2.7 Accessing Variables as Properties ............. 47 2.8 Takeaway: Stuff to Remember ............... 49 Prepared exclusively for Rodney Pearson CONTENTS 6 3 View Controllers 51 3.1 View Controllers start to finish .............. 52 3.2 Multiple View Controllers ................. 55 3.3 Creating and Connecting your Outlets .......... 57 3.4 Creating the new View Controller ............. 60 3.5 The Second View Controller ................ 63 3.6 The Editing View Controller in Interface Builder . 65 4 Table Views 68 4.1 Our first table view app ................... 68 4.2 Getting the table view to display cells .......... 69 4.3 Improving performance by reusing cells ......... 71 4.4 Deleting rows ........................ 73 4.5 Inserting rows ........................ 75 4.6 Sliding in a view for adding data ............. 77 4.7 Hooking the interface up to its view ........... 78 4.8 Presenting the data entry view .............. 80 4.9 Configuring a text field and its keyboard ........ 81 4.10 Passing user input back to the table view controller . 82 4.11 Updating the table view .................. 83 4.12 Designing Table Cells with Interface Builder ...... 84 5 Navigation 92 5.1 Navigating through Mail .................. 92 5.2 The Navigation Controller ................. 93 5.3 Navigation Based Applications .............. 94 5.4 Pushing View Controllers ................. 97 5.5 Customizing the Navigation Bar .............. 99 5.6 Popping View Controllers .................. 104 6 Tab Bar Controllers 106 6.1 When to use tabs ...................... 106 6.2 Creating a Tab Bar Controller ............... 108 6.3 View Controllers in Tab Controllers ............ 109 6.4 Many Controllers ...................... 114 7 File I/O 117 7.1 Exploring Your Filesystem ................. 118 7.2 Reading Data From Files .................. 130 7.3 Asynchronous File Reading ................ 133 7.4 Creating and Deleting Files and Directories ....... 136 7.5 Writing Data To Files .................... 141 Report erratum Prepared exclusively for Rodney Pearson this copy is (B12.0 printing, April 14, 2009) CONTENTS 7 8 Preferences 144 8.1 Displaying a Flippable Preference View in Your Appli- cation ............................. 144 8.2 Using the System Settings Application for Preferences . 152 8.3 Loading Preferences Configured in the Settings Appli- cation ............................. 158 9 The SQLite Database 161 9.1 Creating Your Database .................. 162 9.2 Creating the sample application .............. 164 9.3 Putting Your Database on the Device ........... 166 9.4 Using Your Database on the Device ............ 169 10 Core Data 179 11 Network I/O 180 11.1 Building a Browser in 10 Minutes with UIWebView . 180 11.2 Reading Data from the Network .............. 186 11.3 Handling HTTP Authentication .............. 191 11.4 Using Ad Hoc Network Services with Bonjour . 198 12 Events, Multi Touch and Gestures 207 12.1 Event Model ......................... 207 12.2 Tracking Touches ...................... 209 12.3 Tapping ............................ 211 12.4 Multi-Touch Gestures ................... 213 13 Drawing in Custom Views 219 13.1 Drawing Model ........................ 219 13.2 Vector Drawing ....................... 220 13.3 Paths ............................. 222 13.4 Graphics Context ...................... 228 13.5 Redisplaying a View ..................... 231 14 Drawing Images and Photos 233 14.1 Basic Image Drawing .................... 234 14.2 Customizing the Image Display .............. 236 14.3 Image Picker ......................... 238 Report erratum Prepared exclusively for Rodney Pearson this copy is (B12.0 printing, April 14, 2009) CONTENTS 8 15 Core Animation 243 15.1 Intro to Core Animation .................. 243 15.2 Animating UIView ...................... 244 15.3 Layers ............................. 250 15.4 OpenGL ES .......................... 253 16 Basic Media Playback 257 16.1 Video Playback with MPMoviePlayerController ....... 257 16.2 Supported media formats ................. 263 16.3 Playing Compressed Audio with AVAudioPlayer . 265 16.4 Using AVAudioPlayer’s properties .............. 271 16.5 Using AVAudioPlayer’s level metering ........... 274 17 Advanced Audio Playback 279 17.1 Using the Procedural-C APIs ................ 279 17.2 Getting metadata from audio files ............. 282 17.3 Defining Audio Behavior .................. 285 17.4 Playing System Sounds ................... 292 18 iPhone Location API 299 18.1 Knowing Where ....................... 299 18.2 Location Updates ...................... 303 19 Accelerometer 309 19.1 Getting device orientation ................. 310 19.2 Getting raw accelerometer data .............. 311 19.3 Filtering accelerometer data ................ 318 20 Streaming Audio 324 20.1 Streaming Media Concepts ................. 324 20.2 The Core Audio Frameworks ................ 327 20.3 Recording with Audio Queue Services .......... 328 20.4 Playback with Audio Queue Services ........... 341 20.5 Converting Audio Formats ................. 350 20.6 Next Steps .......................... 358 21 Address Book 359 21.1 Address

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    428 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us