Beginning iPad™ Application Development

Book description

A hands-on approach to iPad application development

Beginning iPad Application Development is written to help jumpstart beginning iPad developers. It covers the various topics in such a manner that you will progressively learn without being overwhelmed by the details. It adopts the philosophy that the best way to learn is by doing, hence the numerous Try It Out sections in all the chapters, which first show you how to build something and then explain how things work.

Although iPad programming is a huge topic, the aim for this book is to get you started with the fundamentals, and help you understand the underlying architecture of the SDK, and appreciate why things are done certain ways. After reading this book (and doing the exercises), you will be well equipped to tackle your next iPad programming challenge.

This book is for the beginning iPad developer who wants to start developing iPad applications using the Apple iPhone SDK. To truly benefit from this book, you should have some background in programming and at least be familiar with object-oriented programming concepts. If you are totally new to the Objective-C language, you might want to jump straight to Appendix D, which provides an overview of the language. Alternatively, you can use Appendix D as a quick reference while you tackle the various chapters, checking out the syntax as you try the exercises. Depending on your learning pattern, one of those approaches may work best for you.

What This Book Covers

This book covers the fundamentals of iPad programming using the iPhone SDK. It is divided into 18 chapters and four appendices.

Chapter 1: Getting Started with iPad Programming covers the various tools found in the iPhone SDK and explains their uses in iPad development.

Chapter 2: Write Your First Hello World! Application gets you started with Xcode and Interface Builder to build a Hello World application. The focus is on getting your hands dirty. More details on the various parts and components are covered in subsequent chapters.

Chapter 3: Views, Outlets, and Actions covers the fundamental concepts of iPad programming: outlets and actions. You learn how outlets and actions allow your code to interact with the visual elements in Interface Builder and why they are an integral part of every iPad application. You will also learn about the various UI widgets known as views that make up the user interface of your iPad application.

Chapter 4: View Controllers discusses the various view controllers available in the iPhone SDK. You will learn how to develop different types of iPad applications - View-based, Window-based, Split View-based, as well as Tab Bar applications.

Chapter 5: Keyboard Inputs shows you how to deal with the virtual keyboard in your iPad. You see how to hide the keyboard on demand and how to ensure that your views are not blocked by the keyboard when it is displayed.

Chapter 6: Screen Rotations demonstrates how you can reorient your application's UI when the device is rotated. You learn about the various events that are fired when the device is rotated. You also learn how to force your application to display in a certain orientation.

Chapter 7: Using the Table View explores one of the most powerful views in the iPhone SDK the Table view. The Table view is commonly used to display rows of data. In this chapter, you also learn how to implement search capabilities in your Table view.

Chapter 8: Application Preferences discusses the use of application settings to persist application preferences. Using application settings, you can access preferences related to your application through the Settings application available on the iPad.

Chapter 9: File Handling shows how you can persist your application data by saving the data to files in your application's sandbox directory. You also learn how to access the various folders available in your application sandbox.

Chapter 10: Database Storage Using SQLLite3 covers the use of the embedded SQLite3 database library to store your data.

Chapter 11: Simple Animations provides an overview of the various techniques you can use to implement simple animations on the iPad. You also learn about the various affine transformations supported by the iPhone SDK.

Chapter 12: Gesture Recognizers provides an overview of the various gesture recognizers available in the iPhone SDK to help your device interpret user's input gestures.

Chapter 13: Accessing the Accelerometer shows how you can access the accelerometer that comes with every iPad. You will also learn how to detect shakes to your device.

Chapter 14: Web Services teaches you how to consume Web services from within your iPad application. You will learn the various ways to communicate with Web services - SOAP, HTTP GET, and HTTP POST. You will also learn how to parse the returning XML result returned by the Web service.

Chapter 15: Bluetooth Programming explores the use of the Game Kit framework for Bluetooth programming. You will learn how to get two iPads to communicate using a Bluetooth connection. You will also learn how to implement voice chatting over a Bluetooth connection.

Chapter 16: Bonjour Programming shows how you can publish services on the network using the Bonjour protocol.

Chapter 17: Apple Push Notification Services explains how you can implement applications that use push notifications. The APNs allows your applications to constantly receive status updates from a service provider even though the application may not be running.

Chapter 18: Displaying Maps shows how to build location-based services application using the Map Kit framework. You will also learn how to obtain geographical locations data and use them to display a map.

Appendix A: Answers to Exercises contains the solutions to the end-of-chapter exercises found in every chapter except Chapter 1.

Appendix B: Getting Around in Xcode provides a quick run-through of the many features in Xcode.

Appendix C: Getting Around in Interface Builder provides an overview of the many features of Interface Builder.

Appendix D: Crash Course in Objective-C provides a crash course in Objective-C. Readers who are new to this language should read this chapter before getting started.

Table of contents

  1. Copyright
  2. ABOUT THE AUTHOR
  3. ABOUT THE TECHNICAL EDITOR
  4. CREDITS
  5. ACKNOWLEDGMENTS
  6. 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
  7. I. Getting Started
    1. 1. Getting Started with iPad 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
      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. Views, Outlets, and Actions
      1. 3.1. OUTLETS AND ACTIONS
      2. 3.2. USING VIEWS
        1. 3.2.1. Using the Alert View
        2. 3.2.2. Using the Action Sheet
        3. 3.2.3. Page Control and Image View
        4. 3.2.4. Using the Web View
      3. 3.3. ADDING VIEWS DYNAMICALLY USING CODE
      4. 3.4. UNDERSTANDING VIEW HIERARCHY
      5. 3.5. SUMMARY
    4. 4. View Controllers
      1. 4.1. THE VIEW-BASED APPLICATION TEMPLATE
        1. 4.1.1. Editing XIB Files
          1. 4.1.1.1. Application Delegate
          2. 4.1.1.2. Controlling Your UI Using View Controllers
      2. 4.2. THE WINDOW-BASED APPLICATION TEMPLATE
        1. 4.2.1. Adding a View Controller and Views Programmatically
        2. 4.2.2. Creating and Connecting Actions
        3. 4.2.3. Switching to Another View
        4. 4.2.4. Animating the Switching of Views
      3. 4.3. THE SPLIT VIEW-BASED APPLICATION TEMPLATE
        1. 4.3.1. Displaying Some Items in the Split View-based Application
      4. 4.4. THE TAB BAR APPLICATION TEMPLATE
      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. 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
  8. II. Displaying and Persisting Data?
    1. 7. Using the Table View
      1. 7.1. A SIMPLE TABLE VIEW
        1. 7.1.1. Adding a Header and Footer
        2. 7.1.2. Adding an Image
        3. 7.1.3. Displaying the Item Selected
        4. 7.1.4. Indenting
        5. 7.1.5. Using the Table View
        6. 7.1.6. Using a Property List
        7. 7.1.7. Adding Indexing
        8. 7.1.8. Adding Search Capability
        9. 7.1.9. Disclosures and Check Marks
      2. 7.2. SUMMARY
    2. 8. Application Preferences
      1. 8.1. CREATING APPLICATION PREFERENCES
      2. 8.2. PROGRAMMATICALLY ACCESSING THE SETTINGS VALUES
        1. 8.2.1. Loading the Settings Values
        2. 8.2.2. Resetting the Preference Settings Values
        3. 8.2.3. Saving the Settings Values
      3. 8.3. SUMMARY
    3. 9. File Handling
      1. 9.1. UNDERSTANDING THE APPLICATION FOLDERS
        1. 9.1.1. Using the Documents and Library Folders
        2. 9.1.2. Storing Files in the Temporary Folder
      2. 9.2. USING PROPERTY LISTS
      3. 9.3. COPYING BUNDLED RESOURCES
      4. 9.4. SUMMARY
    4. 10. Database Storage Using SQLite3
      1. 10.1. USING SQLITE3
      2. 10.2. CREATING AND OPENING A DATABASE
        1. 10.2.1. Examining the Database Created
        2. 10.2.2. Creating a Table
        3. 10.2.3. Inserting Records
        4. 10.2.4. Bind Variables
        5. 10.2.5. Retrieving Records
      3. 10.3. BUNDLING SQLITE DATABASES WITH YOUR APPLICATION
      4. 10.4. SUMMARY
  9. III. Advanced iPad Programming Techniques
    1. 11. Simple Animations
      1. 11.1. USING THE NSTIMER CLASS
        1. 11.1.1. Animating the Visual Change
      2. 11.2. TRANSFORMING VIEWS
        1. 11.2.1. Translation
        2. 11.2.2. Rotation
        3. 11.2.3. Scaling
      3. 11.3. ANIMATING A SERIES OF IMAGES
      4. 11.4. SUMMARY
    2. 12. Recognizing Gestures
      1. 12.1. RECOGNIZING GESTURES
        1. 12.1.1. Tapping
        2. 12.1.2. Pinching
        3. 12.1.3. Rotation
        4. 12.1.4. Panning (or Dragging)
        5. 12.1.5. Swiping
        6. 12.1.6. Long Press
      2. 12.2. DETECTING TOUCHES
        1. 12.2.1. Detecting Single Touch
        2. 12.2.2. Detecting Multi-touches
        3. 12.2.3. Implementing the Pinch Gesture
        4. 12.2.4. Implementing the Drag Gesture
      3. 12.3. SUMMARY
    3. 13. Accessing the Accelerometer
      1. 13.1. USING THE ACCELEROMETER
        1. 13.1.1. Detecting Shakes in iPad Using the Accelerometer
      2. 13.2. USING SHAKE API TO DETECT SHAKES
        1. 13.2.1. Performing an Action When the Device Is Shaken
      3. 13.3. SUMMARY
  10. IV. Network Programming Techniques
    1. 14. Web Services
      1. 14.1. BASICS OF CONSUMING XML WEB SERVICES
        1. 14.1.1. Using SOAP 1.1
        2. 14.1.2. Using SOAP 1.2
        3. 14.1.3. Using HTTP GET
        4. 14.1.4. Using HTTP POST
      2. 14.2. CONSUMING A WEB SERVICE IN YOUR IPAD APPLICATION
        1. 14.2.1. Using HTTP POST to Talk to a Web Service
        2. 14.2.2. Using HTTP GET to Talk to a Web Service
      3. 14.3. PARSING THE XML RESPONSE
      4. 14.4. SUMMARY
    2. 15. Bluetooth Programming
      1. 15.1. USING THE GAME KIT FRAMEWORK
        1. 15.1.1. Searching for Peer Devices
        2. 15.1.2. Sending Data
      2. 15.2. IMPLEMENTING VOICE CHATTING
      3. 15.3. SUMMARY
    3. 16. Bonjour Programming
      1. 16.1. CREATING THE APPLICATION
      2. 16.2. PUBLISHING A SERVICE
      3. 16.3. BROWSING FOR SERVICES
      4. 16.4. SUMMARY
    4. 17. Apple Push Notification Services
      1. 17.1. GENERATING A CERTIFICATE REQUEST
      2. 17.2. GENERATING A DEVELOPMENT CERTIFICATE
      3. 17.3. CREATING AN APP ID
        1. 17.3.1. Configuring an App ID for Push Notifications
        2. 17.3.2. Creating a Provisioning Profile
        3. 17.3.3. Provisioning a Device
      4. 17.4. CREATING THE IPAD APPLICATION
      5. 17.5. CREATING THE PUSH NOTIFICATION PROVIDER
      6. 17.6. SUMMARY
    5. 18. Displaying Maps
      1. 18.1. DISPLAYING MAPS AND MONITORING CHANGES USING THE MAP KIT
      2. 18.2. GETTING LOCATION DATA
        1. 18.2.1. Displaying Location Using a Map
        2. 18.2.2. Getting Directional Information
        3. 18.2.3. Rotating the Map
        4. 18.2.4. Displaying Annotations
        5. 18.2.5. Reverse Geocoding
        6. 18.2.6. Displaying Disclosure Button
      3. 18.3. SUMMARY
  11. 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
        3. A.1.3. Answer to Question 3
      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.2.3. Answer to Question 3
        4. A.2.4. Answer to Question 4
      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.3.4. Answer to Question 4
      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
        2. A.7.2. Answer to Question 2
        3. A.7.3. Answer to Question 3
      8. A.8. CHAPTER 9 EXERCISE SOLUTIONS
        1. A.8.1. Answer to Question 1
        2. A.8.2. Answer to Question 2
        3. A.8.3. Answer to Question 3
      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
        4. A.11.4. Answer to Question 4
        5. A.11.5. Answer to Question 5
      12. A.12. CHAPTER 13 EXERCISE SOLUTIONS
        1. A.12.1. Answer to Question 1
        2. A.12.2. Answer to Question 2
      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
        4. A.14.4. Answer to Question 4
      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
        4. A.15.4. Answer to Question 4
      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
        4. A.16.4. Answer to Question 4
        5. A.16.5. Answer to Question 5
      17. A.17. CHAPTER 18 EXERCISE SOLUTIONS
        1. A.17.1. Answer to Question 1
        2. A.17.2. Answer to Question 2
        3. A.17.3. Answer to Question 3
        4. A.17.4. Answer to Question 4
        5. A.17.5. Answer to Question 5
    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. Errors
        2. B.2.2. Warnings
        3. B.2.3. Setting Breakpoints
        4. B.2.4. Using NSLog
        5. B.2.5. Documentation
    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 Window
        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
    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

Product information

  • Title: Beginning iPad™ Application Development
  • Author(s):
  • Release date: May 2010
  • Publisher(s): Wrox
  • ISBN: 9780470641651