Beginning iPhone® SDK Programming with Objective-C®

Book description

Everything you need to know to start creating native applications for the iPhone and iPod Touch

The iPhone SDK and the Xcode tools are the official Apple tools used for creating native iPhone applications. This information-packed book presents a complete introduction to the iPhone SDK and the Xcode tools, as well as the Objective-C language that is necessary to create these native applications. Solid coverage and real-world examples walk you through the process for developing mobile applications for the iPhone that can then be distributed through Apple's iTunes Application store.

The hands-on approach shows you how to develop your first iPhone application while getting you acquainted with the iPhone SDK and the array of Xcode tools. A thorough tutorial on the features and syntax of the Objective-C language helps you get the most out of the iPhone SDK, and an in-depth look at the features of the iPhone SDK enables you to maximize each of these features in your applications.

  • Provides an introductory look at how the iPhone SDK and Xcode tools work with the Objective-C language to create native iPhone applications

  • Familiarizes you with the latest version of the iPhone SDK and the newest Xcode tools that ship with Snow Leopard

  • Walks you through developing your first iPhone applications

  • Focuses on the features and syntax of the Objective-C language so that you can get the most out of the iPhone SDK

With this hands-on guide, you'll quickly get started developing applications for the iPhone with both the iPhone SDK and the latest Xcode tools.

Note: CD-ROM/DVD and other supplementary materials are not included as part of eBook file.

Table of contents

  1. Copyright
  2. ABOUT THE AUTHOR
  3. CREDITS
  4. ACKNOWLEDGMENTS
  5. INTRODUCTION
    1. WHO THIS BOOK IS FOR
    2. WHAT THIS BOOK COVERS
    3. HOW THIS BOOK IS STRUCTURED
    4. WHAT YOU NEED TO USE THIS BOOK
    5. CONVENTIONS
    6. SOURCE CODE
    7. ERRATA
    8. P2P.WROX.COM
  6. I. Getting Started
    1. 1. Getting Started with iPhone Programming
      1. 1.1. OBTAINING THE IPHONE SDK
      2. 1.2. COMPONENTS OF THE IPHONE SDK
        1. 1.2.1. Xcode
        2. 1.2.2. iPhone Simulator
          1. 1.2.2.1. Features of the iPhone Simulator
          2. 1.2.2.2. Uninstalling Applications from the iPhone Simulator
        3. 1.2.3. Interface Builder
        4. 1.2.4. Instruments
      3. 1.3. ARCHITECTURE OF THE IPHONE OS
      4. 1.4. SOME USEFUL INFORMATION BEFORE YOU GET STARTED
        1. 1.4.1. Versions of iPhone OS
        2. 1.4.2. Testing on Real Devices
        3. 1.4.3. Screen Resolution
        4. 1.4.4. Single-Window Applications
        5. 1.4.5. No Background Applications
        6. 1.4.6. Restrictions on Calling Third-Party Applications
      5. 1.5. SUMMARY
    2. 2. Write Your First Hello World! Application
      1. 2.1. GETTING STARTED WITH XCODE
        1. 2.1.1. Using Interface Builder
        2. 2.1.2. Changing Screen Orientations
        3. 2.1.3. Views Repositioning
        4. 2.1.4. Writing Some Code
      2. 2.2. CUSTOMIZING YOUR APPLICATION ICON
      3. 2.3. SUMMARY
    3. 3. Outlets, Actions, and View Controllers
      1. 3.1. BASIC CODE AND UI INTERACTIONS
        1. 3.1.1. Editing XIB Files
          1. 3.1.1.1. Delegates
          2. 3.1.1.2. View Controllers
          3. 3.1.1.3. Designing the View Window
          4. 3.1.1.4. Creating Outlets and Actions
          5. 3.1.1.5. Linking View Controller to Outlets and Actions
          6. 3.1.1.6. Exposing Outlets as Properties
          7. 3.1.1.7. Coding the Action
        2. 3.1.2. A More Complex Example
          1. 3.1.2.1. Defining the Outlets and Actions
          2. 3.1.2.2. Connecting the Outlets and Actions
          3. 3.1.2.3. Implementing the Actions
      2. 3.2. VIEW CONTROLLERS
        1. 3.2.1. Adding a View Controller
        2. 3.2.2. Customizing the View
      3. 3.3. SUMMARY
    4. 4. Exploring the Views
      1. 4.1. USING THE VIEWS
        1. 4.1.1. Using the Alert View
        2. 4.1.2. Using the Action Sheet
        3. 4.1.3. Page Control and Image View
        4. 4.1.4. Grouping Views Using the Segmented Control
        5. 4.1.5. Using the Web View
      2. 4.2. ADDING VIEWS DYNAMICALLY USING CODE
      3. 4.3. UNDERSTANDING VIEW HIERARCHY
      4. 4.4. SWITCHING VIEWS
        1. 4.4.1. Animating the Transitions
        2. 4.4.2. Passing Data Between Views
      5. 4.5. SUMMARY
    5. 5. Keyboard Inputs
      1. 5.1. USING THE KEYBOARD
      2. 5.2. CUSTOMIZING THE TYPE OF INPUTS
        1. 5.2.1. Making the Keyboard Go Away
        2. 5.2.2. Set the Keyboard to Number Pad
        3. 5.2.3. Automatically Displaying The Keyboard When The View Is Loaded
      3. 5.3. DETECTING THE PRESENCE OF THE KEYBOARD
      4. 5.4. SUMMARY
    6. 6. Screen Rotations
      1. 6.1. RESPONDING TO DEVICE ROTATIONS
        1. 6.1.1. Different Types of Screen Orientations
        2. 6.1.2. Handling Rotations
          1. 6.1.2.1. willAnimateFirstHalfOfRotationToInterfaceOrientation:
          2. 6.1.2.2. willAnimateSecondHalfOfRotationFromInterfaceOrientation:
          3. 6.1.2.3. willRotateToInterfaceOrientation:
          4. 6.1.2.4. willAnimateRotationToInterfaceOrientation:
      2. 6.2. PROGRAMMATICALLY ROTATING THE SCREEN
        1. 6.2.1. Rotating During Runtime
        2. 6.2.2. Displaying the View in a Specific Orientation When Loading
      3. 6.3. SUMMARY
  7. II. Building Different Types of iPhone Applications
    1. 7. View Controllers
      1. 7.1. CREATING A WINDOW-BASED APPLICATION
        1. 7.1.1. Adding a View Controller Programmatically
        2. 7.1.2. Creating and Connecting Actions
      2. 7.2. SWITCHING TO ANOTHER VIEW
      3. 7.3. ANIMATING THE SWITCHING OF VIEWS
      4. 7.4. SUMMARY
    2. 8. Tab Bar and Navigation Applications
      1. 8.1. TAB BAR APPLICATIONS
        1. 8.1.1. Adding Tab Bar Items
          1. 8.1.1.1. Displaying Tab Bar Applications in Landscape Mode
      2. 8.2. NAVIGATION-BASED APPLICATIONS
        1. 8.2.1. Navigating to Another View
      3. 8.3. SUMMARY
    3. 9. Utility Applications
      1. 9.1. CREATING UTILITY APPLICATIONS
      2. 9.2. TRANSITIONING STYLES
      3. 9.3. ADDING ANOTHER VIEW TO THE UTILITY APPLICATION
      4. 9.4. SUMMARY
  8. III. Displaying and Persisting Data
    1. 10. Using the Table View
      1. 10.1. A SIMPLE TABLE VIEW
        1. 10.1.1. Adding a Header and Footer
        2. 10.1.2. Adding an Image
        3. 10.1.3. Displaying the Item Selected
        4. 10.1.4. Indenting
      2. 10.2. DISPLAYING SECTIONS
        1. 10.2.1. Adding Indexing
        2. 10.2.2. Adding Search Capability
        3. 10.2.3. Disclosures and Check Marks
      3. 10.3. SUMMARY
    2. 11. Application Preferences
      1. 11.1. CREATING APPLICATION PREFERENCES
      2. 11.2. PROGRAMMATICALLY ACCESSING THE SETTINGS VALUES
        1. 11.2.1. Loading the Settings Values
        2. 11.2.2. Resetting the Preference Settings Values
        3. 11.2.3. Saving the Settings Values
      3. 11.3. SUMMARY
    3. 12. Database Storage Using SQLite3
      1. 12.1. USING SQLITE3
      2. 12.2. CREATING AND OPENING A DATABASE
        1. 12.2.1. Examining the Database Created
        2. 12.2.2. Creating a Table
        3. 12.2.3. Inserting Records
        4. 12.2.4. Bind Variables
        5. 12.2.5. Retrieving Records
      3. 12.3. SUMMARY
    4. 13. File Handling
      1. 13.1. UNDERSTANDING THE APPLICATION FOLDERS
        1. 13.1.1. Using the Documents and Library Folders
        2. 13.1.2. Storing Files in the Temporary Folder
      2. 13.2. USING PROPERTY LISTS
      3. 13.3. SUMMARY
  9. IV. Advanced iPhone Programming Techniques
    1. 14. Programming Multi-Touch Applications
      1. 14.1. DETECTING TOUCHES
      2. 14.2. DETECTING MULTI-TOUCHES
        1. 14.2.1. Implementing the Pinch Gesture
        2. 14.2.2. Implementing the Drag Gesture
      3. 14.3. SUMMARY
    2. 15. Simple Animations
      1. 15.1. USING THE NSTIMER CLASS
        1. 15.1.1. Animating the Visual Change
      2. 15.2. TRANSFORMING VIEWS
        1. 15.2.1. Translation
        2. 15.2.2. Rotation
        3. 15.2.3. Scaling
      3. 15.3. ANIMATING A SERIES OF IMAGES
      4. 15.4. SUMMARY
    3. 16. Accessing Built-in Applications
      1. 16.1. SENDING EMAILS
        1. 16.1.1. Invoking Safari
        2. 16.1.2. Invoking the Phone
        3. 16.1.3. Invoking SMS
      2. 16.2. ACCESSING THE CAMERA AND THE PHOTO LIBRARY
        1. 16.2.1. Accessing the Photo Library
        2. 16.2.2. Accessing the Camera
      3. 16.3. ACCESSING THE CONTACTS APPLICATION
        1. 16.3.1. Adding a Contact
        2. 16.3.2. Removing a Contact
      4. 16.4. SUMMARY
    4. 17. Accessing the Hardware
      1. 17.1. USING THE ACCELEROMETER
      2. 17.2. DETECTING SHAKES IN IPHONE OS2 AND EARLIER
      3. 17.3. USING SHAKE API TO DETECT SHAKES IN OS 3.0
      4. 17.4. PERFORMING AN ACTION WHEN THE DEVICE IS SHAKEN
      5. 17.5. LOCATION-BASED SERVICES
        1. 17.5.1. Displaying Maps
      6. 17.6. SUMMARY
  10. V. Appendices
    1. A. Answers to Exercises
      1. A.1. CHAPTER 2 EXERCISE SOLUTIONS
        1. A.1.1. Answer to Question 1
        2. A.1.2. Answer to Question 2
      2. A.2. CHAPTER 3 EXERCISE SOLUTIONS
        1. A.2.1. Answer to Question 1
        2. A.2.2. Answer to Question 2
      3. A.3. CHAPTER 4 EXERCISE SOLUTIONS
        1. A.3.1. Answer to Question 1
        2. A.3.2. Answer to Question 2
        3. A.3.3. Answer to Question 3
      4. A.4. CHAPTER 5 EXERCISE SOLUTIONS
        1. A.4.1. Answer to Question 1
        2. A.4.2. Answer to Question 2
        3. A.4.3. Answer to Question 3
      5. A.5. CHAPTER 6 EXERCISE SOLUTIONS
        1. A.5.1. Answer to Question 1
        2. A.5.2. Answer to Question 2
      6. A.6. CHAPTER 7 EXERCISE SOLUTIONS
        1. A.6.1. Answer to Question 1
        2. A.6.2. Answer to Question 2
        3. A.6.3. Answer to Question 3
      7. A.7. CHAPTER 8 EXERCISE SOLUTIONS
        1. A.7.1. Answer to Question 1
      8. A.8. CHAPTER 9 EXERCISE SOLUTIONS
        1. A.8.1. Answer to Question 1
        2. A.8.2. Answer to Question 2
      9. A.9. CHAPTER 10 EXERCISE SOLUTIONs
        1. A.9.1. Answer to Question 1
        2. A.9.2. Answer to Question 2
        3. A.9.3. Answer to Question 3
      10. A.10. CHAPTER 11 EXERCISE SOLUTIONS
        1. A.10.1. Answer to Question 1
        2. A.10.2. Answer to Question 2
        3. A.10.3. Answer to Question 3
      11. A.11. CHAPTER 12 EXERCISE SOLUTIONS
        1. A.11.1. Answer to Question 1
        2. A.11.2. Answer to Question 2
        3. A.11.3. Answer to Question 3
      12. A.12. CHAPTER 13 EXERCISE SOLUTIONS
        1. A.12.1. Answer to Question 1
        2. A.12.2. Answer to Question 2
        3. A.12.3. Answer to Question 3
      13. A.13. CHAPTER 14 EXERCISE SOLUTIONS
        1. A.13.1. Answer to Question 1
        2. A.13.2. Answer to Question 2
        3. A.13.3. Answer to Question 3
      14. A.14. CHAPTER 15 EXERCISE SOLUTIONS
        1. A.14.1. Answer to Question 1
        2. A.14.2. Answer to Question 2
        3. A.14.3. Answer to Question 3
      15. A.15. CHAPTER 16 EXERCISE SOLUTIONS
        1. A.15.1. Answer to Question 1
        2. A.15.2. Answer to Question 2
        3. A.15.3. Answer to Question 3
      16. A.16. CHAPTER 17 EXERCISE SOLUTIONS
        1. A.16.1. Answer to Question 1
        2. A.16.2. Answer to Question 2
        3. A.16.3. Answer to Question 3
    2. B. Getting Around in Xcode
      1. B.1. LAUNCHING XCODE
        1. B.1.1. Project Types Supported
        2. B.1.2. Customizing the Toolbar
        3. B.1.3. Code Sense
        4. B.1.4. Running the Application
      2. B.2. DEBUGGING YOUR APPLICATIONS
        1. B.2.1. Error
        2. B.2.2. Warnings
        3. B.2.3. Setting Breakpoints
        4. B.2.4. Using NSLog
        5. B.2.5. Documentations
        6. B.2.6. Research Assistant
      3. B.3. SUMMARY
    3. C. Getting Around in Interface Builder
      1. C.1. .XIB WINDOW
      2. C.2. DESIGNING THE VIEW
      3. C.3. INSPECTOR WINDOW
        1. C.3.1. Attributes Inspector pane
        2. C.3.2. Connections Inspector window
        3. C.3.3. Size Inspector window
        4. C.3.4. Identity Inspector window
      4. C.4. LIBRARY
      5. C.5. OUTLETS AND ACTIONS
        1. C.5.1. Creating Outlets and Actions
        2. C.5.2. Connecting Outlets and Actions
          1. C.5.2.1. Method 1
          2. C.5.2.2. Method 2
      6. C.6. SUMMARY
    4. D. Crash Course in Objective-C
      1. D.1. DIRECTIVES
      2. D.2. CLASSES
        1. D.2.1. @interface
        2. D.2.2. @implementation
        3. D.2.3. @class
        4. D.2.4. Class Instantiation
        5. D.2.5. Fields
        6. D.2.6. Access Privileges
        7. D.2.7. Methods
        8. D.2.8. Message Sending (Calling Methods)
        9. D.2.9. Properties
        10. D.2.10. Initializers
      3. D.3. MEMORY MANAGEMENT
        1. D.3.1. Reference Counting
          1. D.3.1.1. alloc
          2. D.3.1.2. new
          3. D.3.1.3. retain
          4. D.3.1.4. release
          5. D.3.1.5. Convenience Method and Autorelease
          6. D.3.1.6. Autorelease Pools
          7. D.3.1.7. dealloc
          8. D.3.1.8. Memory Management Tips
      4. D.4. PROTOCOLS
        1. D.4.1. Delegate
      5. D.5. SELECTORS
      6. D.6. CATEGORIES
      7. D.7. SUMMARY
    5. E. Testing on an Actual iPhone or iPod Touch
      1. E.1. SIGN UP FOR THE IPHONE DEVELOPER PROGRAM
      2. E.2. START YOUR XCODE
      3. E.3. GENERATING A CERTIFICATE SIGNING REQUEST
      4. E.4. LOGGING IN TO THE IPHONE DEVELOPER PROGRAM PORTAL
      5. E.5. SUMMARY

Product information

  • Title: Beginning iPhone® SDK Programming with Objective-C®
  • Author(s):
  • Release date: January 2010
  • Publisher(s): Wrox
  • ISBN: 9780470500972