Let's say you have an idea for a killer iPhone app. Where do you begin? Head First iPhone Development will help you get your first application up and running in no time. You'll quickly learn to use iPhone SDK tools, including Interface Builder and Xcode, and master Objective-C programming principles that will make your app stand out. It's a complete learning experience for creating eye-catching, top-selling iPhone applications.
Put Objective-C core concepts to work, including message passing, protocols, properties, and memory management
Take advantage of iPhone patterns such as datasources and delegates
Preview your applications in the iPhone Simulator
Build complicated interactions that utilize multiple views, data entry/editing, and iPhone rotation
Work with iPhone's camera, GPS, and accelerometer
Create interactive, entertaining games
Optimize, test, and distribute your application
We think your time is too valuable to waste struggling with new concepts. Using the latest research in cognitive science and learning theory to craft a multi-sensory learning experience, Head First iPhone Development provides a visually-rich format designed for the way your brain works, not a text-heavy approach that puts you to sleep.
Table of Contents
- Advance Praise for Head First iPhone Development
- The Authors
how to use this book: Intro
- Who is this book for?
- We know what you're thinking.
- And we know what your brain is thinking.
- Metacognition: thinking about thinking
- Here's what YOU can do to bend your brain into submission
- Read me
- The technical review team
- Safari® Books Online
1. getting started: Going mobile
- 1.1. There's a lot of buzz and a lot of money tied up in the App Store...
- 1.2. Mobile applications aren't just ported desktop apps
- 1.3. Anatomy of an iPhone app
- 1.4. Mike can't make a decision
- 1.5. Make a good first impression
- 1.6. It all starts with the iPhone SDK
- 1.7. Xcode includes app templates to help you get started
- 1.8. Xcode is the hub of your iPhone project...
- 1.9. ...and plays a role in every part of writing your app
- 1.10. Build your interface using... Interface Builder
- 1.11. Add the button to your view
- 1.12. The iPhone Simulator lets you test your app on your Mac
- 1.13. What happened?
- 1.14. Use Interface Builder to connect UI controls to code
- 1.15. Interface Builder lists which events a component can trigger
- 1.16. Elements dispatch events when things happen to them
- 1.17. Connect your events to methods
- 1.18. Your iPhone Toolbox
2. iPhone app patterns: Hello @twitter!
- 2.1. First we need to figure out what Mike (really) wants
- 2.2. App design rules—the iPhone HIG
- 2.3. HIG guidelines for pickers and buttons
- 2.4. Create a new View-based project for InstaTwit
- 2.5. The life of a root view
- 2.6. First, get the data from Mike
- 2.7. Use pickers when you want controlled input
- 2.8. Fill the picker rows with Mike's data
- 2.9. Pickers get their data from a datasource...
- 2.10. There's a pattern for that
- 2.11. First, declare that the controller conforms to both protocols
- 2.12. The datasource protocol has two required methods
- 2.13. Connect the datasource just like actions and outlets
- 2.14. There's just one method for the delegate protocol
- 2.15. The button needs to be connected to an event
- 2.16. Add the IBOutlet and property to our view controller
- 2.17. Connect the picker to our outlet
- 2.18. Use our picker reference to pull the selected values
- 2.19. Your iPhone Toolbox
3. objective-c for the iPhone: Twitter needs variety
- 3.1. Renee is catching on....
- 3.2. Make room for custom input
- 3.3. Header files describe the interface to your class
- 3.4. Auto-generated accessors also handle memory management
- 3.5. To keep your memory straight, you need to remember just two things
- 3.6. But when Mike's finished typing...
- 3.7. Customize your UITextField
- 3.8. Components that use the keyboard ask it to appear...
- 3.9. Ask the textField to give up focus
- 3.10. Messages in Objective-C use named arguments
- 3.11. Use message passing to tell our view controller when the Done button is pressed
- 3.12. Something's still not right
- 3.13. Your Objective-C Toolbox
4. multiple views: A table with a view
- 4.1. So, how do these views fit together?
- 4.2. The navigation template pulls multiple views together
- 4.3. The navigation template starts with a table view
- 4.4. A table is a collection of cells
- 4.5. Just a few more drinks
- 4.6. Plists are an easy way to save and load data
- 4.7. Arrays (and more) have built-in support for plists
- 4.8. Use a detail view to drill down into data
- 4.9. A closer look at the detail view
- 4.10. Use the navigation controller to switch between views
- 4.11. Navigation controllers maintain a stack of views
- 4.12. Instantiate a view controller like any other class
- 4.13. Dictionaries store information as key-value pairs
- 4.14. Debugging—the dark side of iPhone development
- 4.15. First stop on your debugging adventure: the console
- 4.16. Interact with your application while it's running
- 4.17. Xcode supports you after your app breaks, too
- 4.18. The Xcode debugger shows you the state of your application
- 4.19. What the heck is going on?
- 4.20. Your iPhone Toolbox
5. plists and modal views: Refining your app
- 5.1. It all started with Sam...
- 5.2. Use the debugger to investigate the crash
- 5.3. Update your code to handle a plist of dictionaries
- 5.4. The detail view needs data
- 5.5. Each dictionary has all the information we need
- 5.6. We have a usability problem
- 5.7. Use a disclosure indicator if your cell leads to more information
- 5.8. Sales were going strong...
- 5.9. Use navigation controller buttons for editing
- 5.10. The button should create a new view
- 5.11. We need a view... but not necessarily a new view
- 5.12. The view controller defines the behavior for the view
- 5.13. A nib file contains the UI components and connections...
- 5.14. You can subclass and extend views like any other class
- 5.15. Use Xcode to create a view controller without a nib
- 5.16. Modal views focus the user on the task at hand...
- 5.17. Any view can present a modal view
- 5.18. Our view doesn't have a navigation bar
- 5.19. Create the save and cancel buttons
- 5.20. Write the save and cancel actions
- 5.21. Your iPhone Toolbox
6. saving, editing, and sorting data: Everyone's an editor...
- 6.1. Sam is ready to add a Red-Headed School Girl...
- 6.2. ...but the keyboard is in the way
- 6.3. We need to wrap our content in a scroll view
- 6.4. The scroll view is the same size as the screen
- 6.5. The keyboard changes the visible area
- 6.6. iPhone notifies you about the keyboard
- 6.7. Register with the default notification center for events
- 6.8. Keyboard events tell you the keyboard state and size
- 6.9. The table view doesn't know its data has changed
- 6.10. You need to ask the table view to reload its data
- 6.11. The array is out of order, too
- 6.12. Table views have built-in support for editing and deleting
- 6.13. Your iPhone Development Toolbox
7. tab bars and core data: Enterprise apps
- 7.1. HF bounty hunting
- 7.2. Choose a template to start iBountyHunter
- 7.3. Drawing how iBountyHunter works...
- 7.4. Build the fugitive list view
- 7.5. Next up: the captured view
- 7.6. After a quick meeting with Bob...
- 7.7. Core Data lets you focus on your app
- 7.8. Core Data needs to know what to load
- 7.9. Core Data describes entities with a Managed Object Model
- 7.10. Build your Fugitive entity
- 7.11. Whip up a Fugitive class without writing a line
- 7.12. Use an NSFetchRequest to describe your search
- 7.13. Add the database as a resource
- 7.14. The template sets things up for a SQLite DB
- 7.15. The iPhone's application structure defines where you can read and write
- 7.16. Copy the database to the correct place
- 7.17. To be continued...
- 7.18. Your Core Data Toolbox
8. migrating and optimizing with core data: Things are changing
- 8.1. Bob needs documentation
- 8.2. Everything stems from our object model
- 8.3. The data hasn't been updated
- 8.4. Data migration is a common problem
- 8.5. We need to migrate the old data into the new model
- 8.6. Xcode makes it easy to version the data model
- 8.7. Core Data can "lightly" migrate data
- 8.8. Bob has some design input
- 8.9. A quick demo with Bob
- 8.10. Use predicates for filtering data
- 8.11. We need to set a predicate on our NSFetchRequest
- 8.12. Core Data controller classes provide efficient results handling
- 8.13. Time for some high-efficiency streamlining
- 8.14. Next we need to change the search to use the controller...
- 8.15. Refactor viewWillAppear to use the controller
- 8.16. We need to refresh the data
- 8.17. Your Data Toolbox
9. camera, map kit, and core location: Proof in the real world
- 9.1. For Bob, payment requires proof!
- 9.2. The way to the camera...
- 9.3. There's a method for checking
- 9.4. Prompt the user with action sheets
- 9.5. Bob needs the where, in addition to the when
- 9.6. Core Location can find you in a few ways
- 9.7. Add a new framework
- 9.8. Just latitude and longitude won't work for Bob
- 9.9. Map Kit is new with iPhone 3.0
- 9.10. A little custom setup for the map
- 9.11. Annotations require a little more finesse
- 9.12. Your extras Toolbox
- 9.13. It's been great having you here!
A. leftovers: The top 6 things (we didn't cover)
- A.1. #1. Internationalization and Localization
- A.2. Localizing string resources
- A.3. Generating your strings file
- A.4. #2. UIWebView
- A.5. UIWebView properties
- A.6. #3. Device orientation and view rotation
- A.7. Handling view rotations
- A.8. Handling rotation with two different views
- A.9. #4. View animations
- A.10. #5. Accelerometer
- A.11. Understanding the device acceleration
- A.12. #6. A word or two about gaming...
- A.13. Quartz and OpenGL
- B. preparing an app for distribution: Get ready for the App Store
- Title: Head First iPhone Development
- Release date: October 2009
- Publisher(s): O'Reilly Media, Inc.
- ISBN: 9780596809294