Learn Mobile Marketing from this website!

iOS 6 Application Development For Dummies

iOS 6 Application Development For Dummies

Published by
John Wiley & Sons, Inc.
111 River St.
Hoboken, NJ 07030-5774
www.wiley.com.
Copyright ?2013 by John Wiley & Sons, Inc., Hoboken, New Jersey
Published by John Wiley & Sons, Inc., Hoboken, New Jersey
Published simultaneously in Canada
No part of this publication may be reproduced, stored in a retrieval system oriOS 6 Application Development For Dummies
transmitted in any form or by any means, electronic, mechanical, photocopying,
recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the
1976 United States Copyright Act, without either the prior written permission of the
Publisher, or authorization through payment of the appropriate per-copy fee to the
Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-
8400, fax (978) 646-8600. Requests to the Publisher for permission should be
addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street,
Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at
http://www.wiley.com/go/permissions.
Trademarks: Wiley, the Wiley logo, For Dummies, the Dummies Man logo, A
Reference for the Rest of Us!, The Dummies Way, Dummies Daily, The Fun and Easy
Way, Dummies.com, Making Everything Easier, and related trade dress are trademarks
or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates in the United
States and other countries, and may not be used without written permission. All other
trademarks are the property of their respective owners. John Wiley & Sons, Inc., is not
associated with any product or vendor mentioned in this book.
Limit of Liability/Disclaimer of Warranty: The publisher and the author make no
representations or warranties with respect to the accuracy or completeness of the
contents of this work and specifically disclaim all warranties, including without limitation
warranties of fitness for a particular purpose. No warranty may be created or extended
by sales or promotional materials. The advice and strategies contained herein may not
be suitable for every situation. This work is sold with the understanding that the
publisher is not engaged in rendering legal, accounting, or other professional services. If
professional assistance is required, the services of a competent professional person
should be sought. Neither the publisher nor the author shall be liable for damages
arising herefrom. The fact that an organization or Website is referred to in this work as a
citation and/or a potential source of further information does not mean that the author or
the publisher endorses the information the organization or Website may provide or
recommendations it may make. Further, readers should be aware that Internet Websites
listed in this work may have changed or disappeared between when this work was
written and when it is read.
For general information on our other products and services, please contact our
Customer Care Department within the U.S. at 877-762-2974, outside the U.S. at 317-
572-3993, or fax 317-572-4002.
For technical support, please visit www.wiley.com/techsupport.
Wiley also publishes its books in a variety of electronic formats and by print-on-demand.
Not all content that is available in standard print versions of this book may appear or be
packaged in all book formats. If you have purchased a version of this book that did not
include media that is referenced by or accompanies a standard print version, you may
request this media by visiting http://booksupport.wiley.com. For more information about
Wiley products, visit us www.wiley.com.
Library of Congress Control Number: 2012955762
ISBN 978-1-118-50880-0 (pbk); ISBN 978-1-118-55006-9 (ebk); ISBN 978-1-118-
55013-7 (ebk); ISBN 978-1-118-55095-3 (ebk)
Manufactured in the United States of America

iOS 6 Application Development For Dummies®
Visit www.dummies.com/cheatsheet/ios6applicationdevelopment to view this
book’s cheat sheet.
Table of Contents
Introduction
A Bit of History
The iPhone Stands Alone
The iPad Joins the Party
A Universal App
Serial or Parallel Development?
Our Plan for This Book
iOS and Xcode Game Changers
About This Book
Conventions Used in This Book
Foolish Assumptions
How This Book Is Organized
Part I: Getting Started
Part II: Building RoadTrip
Part III: Getting Your Feet Wet — Basic Functionality
Part IV: The Model and Application Structure
Part V: Adding the Application Content
Part VI: The Part of Tens
Icons Used in This Book
Where to Go from Here
Part I: Getting Started
Chapter 1: What Makes a Killer iOS App
Figuring Out What Makes a Great iOS Application
Providing an immersive experience
Making content relevant
Designing for the larger iPad screen
Exploiting the iOS Platform
Exploiting advantages of the system
Accessing the Internet
Knowing the location of the user
Tracking orientation and motion
Tracking users’ fingers on the screen
Playing content
Accessing information from Apple’s apps
Copying, cutting, and pasting between apps
Multitasking, background processing, and notifications
Living large on the big screen
Embracing Device Limitations
Designing for fingers
Balancing memory and battery life
Why Develop iOS Applications?
Developing with Apple’s Expectations in Mind
An Application Ecosystem
Enter the Cloud
Developing an App the Right Way Using the Example App in This Book
What’s Next
Chapter 2: Getting to Know the SDK
Developing Using the SDK
Using Xcode to Develop an App
Creating an Xcode project
Developing the application
The Workspace Window
Workspace areas
Displaying an area’s content
The toolbar and Tab bar
The Organizer window
Chapter 3: The Nuts and Bolts of an Xcode Project
Creating Your Project
Exploring Your Project
The project
The Project editor
The Project navigator
Setting Your Xcode Preferences
Building and Running Your Application
Building an app
The iPad’s Split views
The Log navigator
Running in the Simulator
Interacting with your simulated hardware
Making gestures
Uninstalling apps and resetting your device
Living with the Simulator’s limitations
Adding the Image and Sound Resources and an Application Icon
Standard and Retina display images
Adding the application icons
Run your project with its new icon
Part II: Building RoadTrip
Chapter 4: Storyboards and the User Experience
Introducing the Storyboard
Telling your story
Working with object graphs
Defining What You Want an Application to Do: The RoadTrip Application
Creating the Application Architecture
What You Add Where
Using Frameworks
Using Design Patterns
The iOS design patterns
The Model-View-Controller (MVC) design pattern
Working with Windows and Views
Looking out the window
Admiring the view
The kinds of views you use
View Controllers — the Main Storyboard Players
What About the Model?
It’s Not That Neat
Taking a Look at Other Frameworks
The Foundation framework
The CoreGraphics framework
Even more frameworks
Understanding the MVC in the Project
Chapter 5: Creating the RoadTrip User Interface
Creating Your User Interface in the iPad Storyboard
It’s about the view controller
Using Interface Builder to add the user elements
Working within the Utility Area
Inspector and Quick Help pane
Library pane
Understanding iPad Navigation
Adding a New View Controller
Danger Will Robinson
Adding an identifier to the view controller
Adding the User Interface Objects
View Layout
Turn off Auto Layout
Back to Adding User Interface Objects
Autosizing
Adding the Test Drive button
Massaging the Template Code
Autosizing the Button
Creating the iPhone User Interface
A Quick Auto Layout Example.
Final thoughts
Chapter 6: The Runtime, Managing Memory, and Using Properties
Stepping through the App Life Cycle
UIApplicationMain
Handling events while your application is executing
Knowing what to do when the normal processing of your application is interrupted
An overview of the view controller life cycle
Working within the Managed Memory Model Design Pattern
Understanding memory management
Using reference counting
Automatic Reference Counting (ARC)
Working with variable types according to ARC
Understanding the deadly retain cycle
Observing Low-Memory Warnings
The viewDidUnload method
The didReceiveMemoryWarning method
The applicationDidReceiveMemoryWarning: method
The UIApplicationDidReceiveMemoryWarningNotification: notification
Picking the right memory-management strategy for your application
Customizing the Behavior of Framework Classes
Subclassing
The Delegation pattern
Understanding Declared Properties
What comprises a declared property
Using dot syntax
Setting attributes for a declared property
Writing your own accessors
Accessing instance variables with accessors
Hiding Instance Variables
Chapter 7: Working with the Source Editor
Navigating in the Xcode Source Editors
Using the Jump bar
Organizing your code using the #pragma mark statement
Using the Xcode Source Editor
Using Live Issues and Fix-it
Compiler warnings
The Issue navigator
Accessing Documentation
Getting Xcode help
The Organizer window
The Help menu
Finding and Searching in Your Project
Using the Find command to locate an item in a file
Using the Search navigator to search your project or framework
Using the Symbol navigator
You’re Finally Ready to Code!
Part III: Getting Your Feet Wet — Basic Functionality
Chapter 8: It’s (Finally) Time to Code
Checking for Network Availability
Downloading the Reachability sample
Adding the code to check for reachability
Sprucing Up the Main View
Understanding Autorotation
Writing Bug-Free Code
Working in the Debug area and Debug navigator
Managing breakpoints
What you’ll find in the Debug area
What you’ll find in the Debug navigator
Displaying variables in the Source editor
Tiptoeing through your program
Chapter 9: Adding Outlets and Actions to Your RoadTrip Code
Using Custom View Controllers
Adding the custom view controller
Setting up the TestDriveController in the MainStoryboard for iPad
Understanding Outlets
Adding Outlets
Opening the Assistant editor
Creating the outlet
The Connections inspector
Working with the Target-Action Design Pattern
Using the Target-Action pattern: It’s about controls
Adding an action
How Outlets and Actions Work
Update the iPhone storyboard file
Chapter 10: Adding Animation and Sound to Your App
Understanding iOS Animation
View geometry and coordinate systems
Points versus pixels
A view’s size and position
Working with data structures
Animating a View
Finally, More Code
Implementing the testDrive Method
Understanding Block Objects
Rotating the Object
Working with Audio
Tracking Touches
Animating a Series of Images “In Place”
iPhone versus iPad
Part IV: The Model and Application Structure
Chapter 11: The Trip Model
What’s in the Model
Adding the Model Data
Using property lists
Adding a property list to your project
Adding the First Two Model Classes
Understanding the Trip Interface
Implementing the Trip Class
Initializing objects
Invoking the superclass’s init method
Initializing instance variables
Returning self
Initializing the Destination Class
Creating the Trip Object
More Debugger Stuff
Chapter 12: Implementing the Master View Controller
Setting Up a Custom View Controller for the iPad
Adding a Background Image and Title
Updating the iPhone Storyboard File
Chapter 13: Working with Split View Controllers and the Master View
The Problem with Using a Navigation Controller in Detail View
Using a Navigation Controller in the Master View
Adding a Gesture Recognizer
The Split View Controller
The UISplitViewController delegate
Localization
Back to the main feature
Adding the Toolbar
Adding the button when the view controller is replaced
A Few More Tweaks to the RTMasterViewController
And (a Little Extra) One More Thing
Don’t Forget the iPhone
Chapter 14: Finishing the Basic Application Structure
Extending the iPad Storyboard to Add More Functionality to Your App
Adding the Weather view controller
Adding the Events controller
Adding the remaining controllers
Changing the Split View Controller to a Detail View Controller Relationship
Repeat for iPhone
Part V: Adding the Application Content
Chapter 15: How’s the Weather? Working with Web Views
The Plan
The iPad storyboard
The iPhone storyboard
Setting Up the Weather Controller
Adding the custom view controller
Setting Up WeatherController in the MainStoryboard_iPad file
The Weather Controller
Managing links in a Web view
More Opportunities to Use the Debugger
Unrecognized selector sent to instance
Repeat for the iPhone Storyboard
Adding the WeatherController to the iPhone storyboard file
Test in the iPhone Simulator
Chapter 16: Displaying Events Using a Page View Controller
The Plan
Setting Up the EventsController
Adding the custom view controller
Setting up the EventsController in the MainStoryboard
Adding and setting up the EventPageController in the MainStoryboard
Extending the Trip Model
Adding the Events Class
The EventsController and Its PageViewController
Data sources and delegates
Data source
Delegate
The EventsController
The EventPageController
And Then There’s the Bar Button Item
Adding Events Support to the iPhone Storyboard
Chapter 17: Finding Your Way
The Plan
Setting Up the Map Controller
Adding the custom view controller
Setting up the MapController in the MainStoryboard_iPad
Adding the MapKit framework
Test
Putting MapKit through Its Paces
MKMapView
Enhancing the map
Changing the Map Type
Adding Annotations
Creating the annotation
Displaying the map title and annotations
Going to the Current Location
Update the iPhone Storyboard
Chapter 18: Geocoding
Understanding Geocoding on the iPad
Reverse Geocoding
Chapter 19: Finding a Location
Setting Up the Find Controller
Adding the custom view controller
Setting up FindController in the MainStoryboard_iPad
Implementing the Find Controller
Getting the text
Disabling cell highlighting
Finding the Location
Making the Map Title the Found Location
Adding the FindController to the iPhone Storyboard
Chapter 20: Selecting a Destination
The Plan
Setting Up the DestinationController for the iPad Storyboard
Adding the custom view controller
Setting up the DestinationController in the MainStoryboard_iPad
Adding a Modal View
Implementing a Table View
Creating the Table View
Adding sections
Displaying the cell
Working with user selections
Saving the Destination Choice and Selecting a Destination
Displaying the Destination Table
Testing
Adding Destination Support to the iPhone Storyboard
A Word about Adding Settings
What’s Next?
Part VI: The Part of Tens
Chapter 21: Ten Ways to Extend the RoadTrip App
Add Preferences
Cache Data
Monitor the Current Location’s Distance from the Destination
Post to Facebook and Twitter
Send Postcards from the Road
Add Hotels and Reservations
Create an Itinerary
Make the App Part of an Application Ecosystem
It’s Never Early Enough to Start Speaking a Foreign Language
Provide Some Implementation Enhancements
Chapter 22: Ten Ways to Be a Happy Developer
Keep Things Loosely Coupled
Remember Memory
Don’t Reinvent the Wheel
Understand State Transitions
Do the Right Thing at the Right Time
Avoid Mistakes in Error Handling
Use Storyboards
Remember the User
Keep in Mind That the Software Isn’t Finished Until the Last User Is Dead
Keep It Fun
Cheat Sheet

 

↑ Back to Top