Table of Contents
Introduction
Prerequisites
What’s Changed in the Second Edition?
Our Teaching Philosophy
How To Use This Book
Using an eBook
How This Book Is Organized
Style Choices
Typographical Conventions
Necessary Hardware and Software
1. A Simple iOS Application
Creating an Xcode Project
Building Interfaces
Model-View-Controller
Declarations
Declaring instance variables
Declaring methods
Making Connections
Setting pointers
Setting targets and actions
Summary of connections
Implementing Methods
Build and Run on the Simulator
Deploying an Application
Application Icons
Launch Images
2. Objective-C
Objects
Using Instances
Creating objects
Sending messages
Destroying objects
Writing the RandomPossessions Tool
NSString
NSArray and NSMutableArray
Subclassing an Objective-C Class
Instance variables
Accessor methods
Instance methods
Initializers
Other initializers and the initializer chain
Class methods
Testing your subclass
Exceptions and the Console Window
Fast Enumeration
Challenge
3. Memory Management
Memory Management Basics
Managing memory in C
Managing memory with objects
Reference Counting
Using retain counts
Using autorelease
Accessors and memory management
Implementing dealloc
Simplifying accessors with properties
copy and mutableCopy
Retain count rules
For the More Curious: More on Memory Management
4. Delegation and Core Location
Projects, targets, and frameworks
Core Location
Receiving updates from CLLocationManager
Delegation
Protocols
Delegation, controllers, and memory management
Using the Debugger
Challenge: Heading
For the More Curious: Build Phases, Compiler Errors, and Linker Errors
Preprocessing
Compiling
Linking
5. MapKit and Text Input
Object Diagrams
MapKit Framework
Interface Properties
Being a MapView Delegate
Using the documentation
Your own MKAnnotation
Tagging locations
Putting the pieces together
Challenge: Annotation Extras
Challenge: Reverse Geocoding
6. Subclassing UIView
Creating a Custom View
The drawRect: method
Instantiating a UIView
Drawing Text and Shadows
Using UIScrollView
Zooming
Hiding the Status Bar
Challenge: Colors
For the More Curious: Retain Cycles
For the More Curious: Redrawing Views
7. View Controllers
View Controllers and XIB Files
Using View Controllers
Creating the UITabBarController
Creating view controllers and tab bar items
Creating views for the view controllers
Appearing and Disappearing Views
The View Controller Lifecycle and Low-Memory Warnings
View Controller Subclasses and Templates
Challenge: Map Tab
8. The Accelerometer
Setting Up the Accelerometer
Getting Accelerometer Data
Orientation and Scale of Acceleration
Using Accelerometer Data
Smoothing Accelerometer Data
Detecting Shakes
Challenge: Changing Colors
For the More Curious: Filtering and Frequency
For the More Curious: Retina Display
9. Notification and Rotation
Notification Center
UIDevice Notifications
Autorotation
Setting autoresizing masks programmatically and bitwise operations
Forcing Landscape Mode
Challenge: Proximity Notifications
For the More Curious: Overriding Autorotation
10. UITableView and UITableViewController
Beginning the Homepwner Application
UITableViewController
Subclassing UITableViewController
UITableView’s Data Source
PossessionStore: a singleton
Implementing data source methods
UITableViewCells
Creating and retrieving UITableViewCells
Reusing UITableViewCells
Code Snippet Library
Challenge: Sections
11. Editing UITableView
Editing Mode
Adding Rows
Deleting Rows
Moving Rows
12. UINavigationController
UINavigationController
UINavigationBar
An Additional UIViewController
Navigating with UINavigationController
Pushing view controllers
Passing data between view controllers
Appearing and disappearing views
Challenge: Number Pad
13. Camera
Displaying Images and UIImageView
Taking pictures and UIImagePickerController
ImageStore
Creating and using keys
Dismissing the keyboard
Challenge: Removing an Image
For the More Curious: Recording Video
14. UIPopoverController and Modal View Controllers
Universalizing Homepwner
UIPopoverController
Modal View Controllers
Dismissing modal view controllers
Modal view controller styles
Writing a view controller delegate protocol
Modal view controller transitions
15. Saving, Loading, and Multitasking
Application Sandbox
Constructing a file path
Archiving
Archiving objects
Unarchiving objects
Application States, Transitions, and Multitasking
Writing to filesystem with NSData
More on Low-Memory Warnings
Model-View-Controller-Store Design Pattern
Challenge: Archiving Whereami
For The More Curious: Application State Transitions
For the More Curious: Reading and Writing to the filesystem
For the More Curious: The Application Bundle
16. Subclassing UITableViewCell
Creating HomepwnerItemCell
Creating subviews
Laying out subviews
Using the custom cell
Image Manipulation
Challenge: Accessory Indicators
Challenge: Shrinking the Main Image
17. Core Data
Object-Relational Mapping
Moving Homepwner to Core Data
The model file
NSManagedObject and subclasses
Updating PossessionStore
Adding AssetTypes to Homepwner
More About SQL
Trade-offs of Persistence Mechanisms
Challenge: New Asset Types
Challenge: Assets on the iPad
18. Localization
Internationalization using NSLocale
Localizing Resources
NSLocalizedString and Strings Tables
Challenge: Another Localization
For the More Curious: NSBundle’s Role in Internationalization
19. Settings
Updating Whereami
NSUserDefaults
For the More Curious: The Settings Application
20. Touch Events and UIResponder
Touch Events
Creating the TouchTracker Application
Turning Touches into Lines
The Responder Chain
Challenge: Saving and Loading
Challenge: Circles
For the More Curious: UIControl
21. Instruments
The Static Analyzer
Instruments
The Allocations Instrument
Time Profiler Instrument
Xcode Schemes
Creating a new scheme
Build Settings
22. Core Animation Layer
Layers and views
Creating a CALayer
Layer Content
Implicitly Animatable Properties
For the More Curious: Programmatically Generating Content
For the More Curious: Layers, Bitmaps, and Contexts
Challenge: Dynamic Layer Content
23. Controlling Animation with CAAnimation
Animation Objects
Spinning with CABasicAnimation
Timing functions
Animation completion
Bouncing with a CAKeyframeAnimation
Challenge: More Animation
For the More Curious: The Presentation Layer and the Model Layer
24. Blocks and Categories
Colorizing TouchDrawView
Blocks
Blocks as variables
Capturing variables
Using blocks with other built-in methods
Keeping code compact with blocks
Categories
For the More Curious: Memory Management and Blocks
For the More Curious: Pros and Cons of Callback Options
25. Web Services and UIWebView
Web Services
Starting the Nerdfeed application
Fetching data from a URL
Working with NSURLConnection
Parsing XML
A quick tip on logging
UIWebView
For the More Curious: NSXMLParser
For the More Curious: The Request Body
For the More Curious: Credentials
Challenge: More Data
Challenge: More UIWebView
26. UISplitViewController
Splitting Up Nerdfeed
Master-Detail Communication
Displaying the Master View Controller in Portrait Mode
Universalizing Nerdfeed
27. Media Playback and Background Execution
Creating the MediaPlayer Application
System Sounds
Registering system sounds
Playing system sounds
Compressed Audio Files
Playing Movie Files
MPMoviePlayerViewController
Preloading video
Background Processes
Guidelines for background execution
Other forms of background execution
Low-level APIs
Challenge: Audio Recording
28. Bonjour and Web Servers
Bonjour
Creating CocoaServer
Publishing a Bonjour service
Browsing for services via Bonjour
HTTP Communication
Writing a web server in Objective-C
Getting address data from the server
Byte ordering
Making service requests
Receiving service requests
For the More Curious: TXTRecords
29. Push Notifications and Networking
Preparing Client for Push Notifications
Registering for notifications
Provisioning for push notifications
Delivering a Push Notification
Getting the token to the provider
Sending Push Notifications
Connecting to Apple’s server with NSStream
Additional Client-side Notification Handling
Sounds and badges
Accessing data in notifications
The Production Server and Moving Forward
For the More Curious: The Feedback Service
30. Afterword
What to do next
Shameless plugs
Index
More From Big Nerd Ranch...