You are previewing Xcode 4 iOS Development.
O'Reilly logo
Xcode 4 iOS Development

Book Description

Use the powerful Xcode 4 suite of tools to build applications for the iPhone and iPad from scratch

  • Learn how to use Xcode 4 to build simple, yet powerful applications with ease

  • Each chapter builds on what you have learned already

  • Learn to add audio and video playback to your applications

  • Plentiful step-by-step examples, images, and diagrams to get you up to speed in no time with helpful hints along the way

  • A practical guide to building your own fun and exciting iOS applications rapidly using Xcode 4

  • In Detail

    The iPhone is one of the hottest mobile devices on the planet. Whether you are just starting out with iOS Development or already have some knowledge in this area, you will benefit from what this book covers. Using this book's straightforward, step-by-step approach, you will go from Xcode 4 apprentice to Xcode 4 Jedi master in no time.

    Xcode 4 iOS Development Beginner's Guide will help you learn to build simple, yet powerful applications for the iPhone from the ground up. You will master the Xcode 4 tools and skills needed to create applications that are simple yet, like Yoda, punch far above their weight.

    You will start by learning about the Xcode 4 Development Tools, Xcode IDE, iOS Simulator, Objective-C 2, and Organizer. Then you will jump straight in and create applications using Xcode and Interface Builder. You finish up by learning how to build, package, and distribute your application to the Apple App Store.

    This book will teach you how to go about building simple applications from scratch, you will master how to download and install the Xcode 4 Development Tools, get to know the development environment and how to build great user interfaces (using Interface Builder), learn about the different iOS frameworks, learn how to implement video and audio playback, learn how to sense motion using the Accelerometer and Gyroscope, and how to improve the reliability and performance of your applications.

    After reading Xcode 4 iOS Development Beginner's Guide, you will be able to write your own applications for the iPhone with supreme efficiency. There are a lot of examples and images provided to get you up to speed quickly.

    Using this book's easy to follow step-by-step approach you will harness Xcode 4's firepower to create some stunning applications for your iPhone

    Table of Contents

    1. Xcode 4 iOS Development
      1. Xcode 4 iOS Development
      2. Credits
      3. About the Author
      4. Acknowledgement
      5. About the Reviewers
      6. www.PacktPub.com
        1. Support files, eBooks, discount offers and more
          1. Why Subscribe?
          2. Free Access for Packt account holders
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
          1. Time for action – heading
            1. What just happened?
          2. Pop quiz – heading
          3. Have a go hero – heading
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
          4. Questions
      8. 1. Introducing Xcode 4 Tools for iOS Development
        1. Development using the Xcode tools
          1. iPhone SDK core components
        2. Inside Xcode, Cocoa, and Objective-C
        3. The iPhone Simulator
        4. Layers of the iOS architecture
          1. The Core OS layer
          2. The Core Services layer
          3. The Media layer
          4. The Cocoa-Touch layer
        5. Understanding Cocoa, the language of the Mac
          1. What are Design Patterns?
          2. What is the difference between Cocoa and Cocoa-Touch?
        6. The Model-View-Controller
        7. What is Object-Oriented Programming?
          1. What is Data Hiding?
        8. What is Objective-C?
          1. Directives
        9. Objective-C classes
          1. The @interface directive
          2. The @implementation directive
          3. Class instantiation
          4. Class access privileges
        10. Introducing the Xcode Developer set of tools
          1. Introducing the core tools
          2. The Welcome to Xcode screen
          3. The Xcode Integrated Development Environment
          4. Features of the iPhone Simulator
        11. Companion tools and features
        12. Instruments
        13. iPhone OS4 SDK new features
        14. Summary
      9. 2. Introducing the Xcode 4 Workspace
        1. Downloading and installing the iOS SDK
          1. Removing the Xcode Developer Tools
        2. Getting to know the Xcode Development Environment
          1. One environment to bind them all
            1. Working within a single-development environment
            2. Creating a new project
            3. Migrating older projects into the new environment
            4. Writing a simple iPhone application
        3. Time for action – creating your first iPhone application
          1. What just happened
          2. Working with the new Xcode Assistant
        4. Introducing the Xcode 4 Workspace Environment
          1. Application ToolBar
          2. Application Status Bar/Activity Window
          3. WorkSpace Settings
        5. Introducing the Unified Navigation UI
          1. Listing files in a project
          2. Sorted Symbols
          3. Central Search Interface
          4. Issues Tracking
          5. Using Static Analysis to find potential problems
          6. Debugging data with Compressionable Stack Traces
          7. Active/inactive breakpoints
          8. Collection of Logs
          9. Jump Bar
          10. Using Code Assistants
          11. Introducing the new and improved LLVM Compiler 2.0
          12. Version Editor
          13. File Templates Library
          14. Code Snippets Library
          15. Object Library
          16. Media Library
          17. Resetting Xcode's Development Environment Settings
        6. Xcode Workspace Preferences
          1. General
          2. Behaviors
          3. Fonts & Colors
          4. Text Editing
          5. Key Bindings
          6. Documentation
          7. Locations
          8. Source Trees
          9. Distributed Builds
        7. Summary
      10. 3. Working with the Interface Builder
        1. Getting to know the Interface Builder environment
          1. Adding Controls to your user interface
        2. Time for action – creating the HelloXcode4_GUI application
          1. What just happened?
          2. Application structure of our HelloXcode4 example application
            1. Main.m
              1. HelloXcode4_GUIAppDelegate.h
              2. HelloXcode4_GUIAppDelegate.m
          3. The MainWindow.xib file
          4. The Core Application Architecture layer
          5. The application life cycle
        3. Time for action – adding object controls to our View
          1. What just happened?
          2. Understanding Rotatable Interfaces
        4. Time for Action – enabling Interface Rotation
          1. What just happened?
          2. Relocating controls within the view on Rotation
        5. Making our Components work together
        6. Time for action – binding Control Objects
          1. What just happened?
        7. Time for action – repositioning the Controls
          1. What just happened?
          2. Enhancing our iPhone application
        8. Time for action – hiding the keyboard
          1. What just happened?
          2. Have a go hero – enhancing the HelloXcode4 example
        9. Introducing Document-based applications
        10. Time for action – creating a Document-based application
          1. What just happened?
          2. File saving and loading
        11. Time for action – implementing file saving and loading
          1. What just happened?
          2. Pop quiz – Actions and Rotatable Interfaces
        12. Summary
      11. 4. Working with the Xcode Frameworks
        1. Introducing the Frameworks
        2. Using Frameworks and APIs in iPhone development
          1. Core Data Frameworks
          2. Building a simple database application
        3. Time for action – creating the Core Data application
          1. What just happened?
          2. AV Foundation Frameworks
            1. Playing an audio File
            2. Creating an application to play an audio file
        4. Time for action – creating the MusicPlayer application
          1. What just happened?
            1. Playing a movie using Media Player
        5. Time for action – creating the MoviePlayer application
          1. What just happened?
          2. Core Location Framework
        6. Time for action – making your application location aware
          1. What just happened?
          2. Map Kit Framework—new and improved
        7. Time for action – creating a simple geographical application
          1. What just happened?
        8. New Framework APIs
          1. What just happened?
          2. Pop quiz – Core Data / Media Playback and Core Location
        9. Summary
      12. 5. Designing Application Interfaces using MVC
        1. Developing iOS applications using MVC design
          1. Reusing tested (or standard) solutions: Design patterns
            1. Understanding the Model-View-Controller design pattern
        2. Implementing MVC using Xcode and Interface Builder
        3. Time for action – building a Pizza order application
          1. What just happened?
        4. Time for action – binding our Controls using Outlets and Actions
          1. What just happened?
          2. Implementing views
          3. Implementing view controllers
        5. Time for action – declaring input field as a property of View Controller
          1. What just happened?
        6. Creating a view-based application template
        7. Time for Action – creating the FavoriteColor application
          1. What just happened?
        8. Time for action – binding our Controls using Outlets and Actions
          1. What just happened?
          2. Implementing Table Views
        9. Time for action – creating a Table view application
          1. What just happened?
            1. Grouping row items into sections
        10. Time for action – grouping row items in our TableViewExample application
          1. What just happened?
          2. Understanding Navigation-based applications
          3. Using Switches, Sliders, Segmented Controls, and Web Views
        11. Time for action – creating the SwitchesSlidersSegments project
          1. What just happened?
        12. Time for action – binding our Controls using Outlets and Actions
          1. What just happened?
          2. Creating an application to scroll through large content
        13. Time for action – creating the ScrollingViews project
          1. What just happened?
        14. Time for action – binding our Controls using Outlets and Actions
          1. What just happened?
          2. Understanding Pickers
            1. Date Pickers
        15. Time for action – creating the Date Picker project
          1. What just happened?
        16. Time for action – binding our Controls using Outlets and Actions
          1. What just happened?
            1. Custom Pickers
        17. Time for Action – creating the Custom Picker project
          1. What just happened?
        18. Time for action – binding our Controls using Outlets and Actions
          1. What just happened?
          2. Handling basic user input and output
            1. Button Controls
            2. Text Fields
            3. Text Views
            4. Labels
          3. Using Text Fields, Text Views, and Buttons
        19. Time for action – creating application with Text fields, Text Views, and Buttons
          1. What just happened?
        20. Time for action – binding our Controls using Outlets and Actions
          1. What just happened?
          2. Have a go hero – modifying the Table View example
          3. Pop quiz – Table Views / repositioning Controls
        21. Summary
      13. 6. Displaying Notification Messages
        1. Exploring the notification methods
        2. Generating alerts
        3. Time for action – creating the GetUsersAttention application
          1. What just happened?
        4. Time for action – adding the AudioToolbox Framework to our application
          1. What just happened?
          2. Pop quiz – Frameworks
          3. Building our user interface
        5. Time for action – adding controls to our View
          1. What just happened?
          2. Creating events
        6. Time for action – implementing the Show Activity Indicator method
          1. What just happened?
          2. Have a go hero – adding a second activity indicator
          3. Pop quiz – Activity Indicators
        7. Time for action – implementing the Display Alert Dialog method
          1. What just happened?
          2. Responding to Alert Dialog Button presses
          3. Have a go hero – adding additional buttons and creating the events
          4. Pop quiz – Alert Dialogs and Button Indexes
          5. Using Action Sheets to associate with a view
        8. Time for action – implementing the Display Action Sheet method
          1. What just happened?
          2. Responding to Action Sheet Button presses
            1. Customizing an Action Sheet
        9. Time for action – handling alerts via sounds and vibrations
          1. What just happened?
          2. Have a go hero – adding Action Sheet items / changing appearance
          3. Pop quiz – sounds and vibrations
        10. Summary
      14. 7. Exploring the MultiTouch Interface
        1. Introducing the MultiTouch architecture
          1. Detecting taps
        2. Time for action – creating the TapExample project
          1. What just happened?
        3. Time for action – binding our Controls
          1. What just happened?
          2. Have a go hero – modify the program to change background
          3. Pop quiz – tap counts
          4. Detecting swipes
        4. Time for action – creating the SwipeExample project
          1. What just happened?
          2. Have a go hero – adjust the delayFactor and change the background
          3. Pop quiz – tracking and identifying swipes
          4. Detecting pinches
        5. Time for action – creating the PinchExample project
          1. What just happened?
          2. Have a go hero – handling more than two fingers
          3. Pop quiz – pinches and transformations
          4. Detecting shakes
        6. Time for action – creating the ShakeExample project
          1. What just happened
        7. Time for action – implementing the motionBegan, motionEnded, and motionCancelled methods
          1. What just happened?
          2. Have a go hero – modifying the ShakeExample application
          3. Pop quiz – motion events
        8. Exploring the Accelerometer/Gyroscope
          1. Understanding the Core Motion Framework
          2. Sensing orientation
        9. Time for action – creating the OrientationExample project
          1. What just happened?
          2. Have a go hero – modify the OrientationExample application
          3. Pop quiz – sensing orientation
          4. Detecting device tilting
        10. Time for action – creating the AccelGyroExample project
          1. What just happened?
        11. Summary
      15. 8. Debugging Xcode Projects
        1. Introducing the new and improved Debugger
          1. Debugger toolbar
          2. Stack trace panel
          3. Disassembly view
          4. Code Editor window
          5. Console output window
        2. Creating a new debugging project
        3. Time for action – creating the DebuggingExample project
          1. What just happened?
        4. Running and debugging the project
          1. Handling errors
            1. Runtime errors
            2. Syntax errors
            3. Logic errors
          2. Using Fix-it to correct code as you type
        5. Time for action – setting up the LLVM compiler
          1. What just happened?
          2. Debugging with breakpoints
          3. Using NSLog to track changing properties
        6. Exploring the new Debugger
          1. Debugging features in the Code Editor
          2. The Activity Viewer/Progress window
          3. Defining a scheme for project builds using the Scheme Editor
        7. Time for action – using the Scheme Editor to define a Scheme
          1. What just happened?
          2. Viewing the Static Analysis results
        8. Time for action – running the Static Analyzer
          1. What just happened?
        9. Time for action – configuring your project to perform automatic Static Analysis
          1. What just happened?
        10. Time for action – Detecting a memory leak
          1. What just happened?
        11. Time for action – detecting an instance of an uninitialized variable
          1. What just happened?
          2. Viewing the Issues Navigator
          3. Viewing the Program Build log
          4. Understanding and using code completion
        12. Time for action – working with code completion
          1. What just happened?
        13. Time for action – stopping Xcode from alerting you to problems
          1. What just happened?
          2. Navigating through threads and stacks in the Debugger
          3. Have a go hero – Static Analyzer and debugging features
          4. Pop quiz – all about debugging projects
        14. Summary
      16. 9. Source Code Management with the Version Editor
        1. Introducing the new Version Editor
          1. Introducing Subversion
          2. Installing a local Subversion server
          3. Creating a repository
        2. Time for action – setting up a local Subversion repository
          1. What just happened?
          2. Configuring the repository in Xcode
        3. Time for action – configuring the Subversion repository
          1. What just happened?
          2. Adding items to an existing repository
        4. Time for action – adding our TapExample project to the repository
          1. What just happened?
          2. Getting a working copy of the project out of the repository
        5. Time for action – checking out the project from the repository
          1. What just happened?
            1. Xcode source-control features and file statuses
          2. Comparing different versions of a file side-by-side
          3. Using Timeline to select and compare revisions
          4. Using Track Blame to check past check-ins
          5. Using Log Mode to list all revisions chronologically
          6. Using the Repository Organizer to keep track of your files
        6. Using Git to manage multiple projects
        7. Time for action – creating a new Xcode project using Git
          1. What just happened?
        8. Time for action – assigning address book identities within the organizer
          1. What just happened?
          2. Have a go hero – adding a project to a Subversion repository
          3. Pop quiz – Subversion / Version Editor
        9. Summary
      17. 10. Making your Applications Run Smoothly
        1. Introducing Instruments
          1. Tracking down and fixing memory leaks
        2. Time for action – creating the InstrumentsExample project
          1. What just happened?
        3. Time for action – running and Profiling the project
          1. What just happened?
        4. Adding and configuring Instruments
          1. Using the Instruments Library
          2. Locating an Instrument within the Library
          3. Adding and removing Instruments
          4. Configuring an Instrument
          5. Other components of the Instruments family explained
        5. New Instruments in Xcode 4
          1. Automated Testing
          2. Performance and Power Analysis
          3. Time Profiler
          4. Energy Diagnosis
          5. Tracking iPhone graphics performance using OpenGL ES Driver
          6. Have a go hero – adding Instruments to your project
          7. Pop quiz – playing with Instruments
        6. Summary
      18. 11. Distributing your Application
        1. Build configurations debug to release
          1. The iPhone Developer Program
          2. Setting up your iPhone development team
        2. Time for action – setting up the team
          1. What just happened?
          2. Getting an iOS development certificate
        3. Time for action – generating a Certificate Request
          1. What just happened?
        4. Time for action – getting the certificate
          1. What just happened?
          2. Registering devices for testing
        5. Time for action – registering devices
          1. What just happened?
          2. Creating application IDs
        6. Time for action – creating the application ID
          1. What just happened?
          2. Creating a Provisioning Profile
        7. Time for action – creating the profile
          1. What just happened?
          2. Using the Provisional Profile to install an App on an iOS device
        8. Time for action – creating and deploying the app to an iOS device
          1. What just happened?
          2. Getting a Distribution Certificate for your app
        9. Time for action – getting the Distribution Certificate
          1. What just happened?
          2. Archiving and submitting Apps using Xcode 4
          3. iOS Human Interface Guidelines
          4. Testing your application
          5. Preparing your App for submission through iTunes Connect
          6. Avoiding rejection of your App
          7. Pricing your app
          8. Adding your App to iTunes Connect
        10. Time for action – uploading the application icon and screenshot images
          1. What just happened?
          2. Using iTunes Connect to manage your Apps
          3. Marketing and promoting your app
          4. iOS Developer Documentation
          5. Have a go hero – creating App IDs and submitting your App
          6. Pop quiz – distribution of your App
        11. Summary
      19. A. Pop Quiz Answers
        1. Chapter 3
          1. Actions and Rotatable Interfaces
        2. Chapter 4
          1. Core Data/Media Playback and Core Location
        3. Chapter 5
          1. Table Views/repositioning Controls
        4. Chapter 6
          1. Frameworks
          2. Activity Indicators
          3. Alert Dialogs and Button Indexes
          4. Sounds and vibrations
        5. Chapter 7
          1. Tap counts
          2. Tracking and identifying swipes
          3. Pinches and transformations
          4. Motion events
          5. Sensing orientation
        6. Chapter 8
          1. All about debugging projects
        7. Chapter 9
          1. Subversion/Version Editor
        8. Chapter 10
          1. Playing with Instruments
        9. Chapter 11
          1. Distribution of your App