Table of Contents

Introduction

Prerequisites

What has Changed in the Fourth 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

Model-View-Controller

Designing Quiz

Creating a View Controller

Building an Interface

Creating view objects

Configuring view objects

NIB files

Making connections

Creating Model Objects

Using code-completion

Pulling it all Together

Implementing action methods

Getting the view controller on the screen

Running on the Simulator

Deploying an Application

Application Icons

Launch Images

2. Objective-C

Objects

Using Instances

Creating objects

Sending messages

Destroying objects

Beginning RandomItems

Creating and populating an array

Iterating over an array

Format strings

Subclassing an Objective-C Class

Creating an NSObject subclass

Instance variables

Accessing instance variables

Class vs. instance methods

Overriding methods

Initializers

Class methods

Testing your subclass

More on NSArray and NSMutableArray

Exceptions and Unrecognized Selectors

Challenges

Bronze Challenge: Bug Finding

Silver Challenge: Another Initializer

Gold Challenge: Another Class

Are You More Curious?

For the More Curious: Class Names

For the More Curious: #import and @import

3. Managing Memory with ARC

The Stack

The Heap

ARC and memory management

Pointer Variables and Object Ownership

How objects lose owners

Ownership chains

Strong and Weak References

Properties

Declaring properties

Property attributes

Custom accessors with properties

For the More Curious: Property Synthesis

For the More Curious: Autorelease Pool and ARC History

4. Views and the View Hierarchy

View Basics

The View Hierarchy

Subclassing UIView

Views and frames

Custom Drawing in drawRect:

Drawing a single circle

UIBezierPath

Using the developer documentation

Drawing concentric circles

More Developer Documentation

Bronze Challenge: Draw an Image

For the More Curious: Core Graphics

Gold Challenge: Shadows and Gradients

5. Views: Redrawing and UIScrollView

The Run Loop and Redrawing Views

Class Extensions

Using UIScrollView

Panning and paging

6. View Controllers

Subclassing UIViewController

The view of a view controller

Creating a view programmatically

Setting the root view controller

Another UIViewController

Creating a view in Interface Builder

UITabBarController

Tab bar items

UIViewController Initializers

Adding a Local Notification

Loaded and Appearing Views

Accessing subviews

Interacting with View Controllers and Their Views

Bronze Challenge: Another Tab

Silver Challenge: Controller Logic

For the More Curious: Key-Value Coding

For the More Curious: Retina Display

7. Delegation and Text Input

Text Fields

UIResponder

Configuring the keyboard

Delegation

Protocols

Adding the Labels to the Screen

Motion Effects

Using the Debugger

Using breakpoints

Stepping through code

For the More Curious: main() and UIApplication

Silver Challenge: Pinch to Zoom

8. UITableView and UITableViewController

Beginning the Homepwner Application

UITableViewController

Subclassing UITableViewController

UITableView’s Data Source

Creating BNRItemStore

Implementing data source methods

UITableViewCells

Creating and retrieving UITableViewCells

Reusing UITableViewCells

Code Snippet Library

Bronze Challenge: Sections

Silver Challenge: Constant Rows

Gold Challenge: Customizing the Table

9. Editing UITableView

Editing Mode

Adding Rows

Deleting Rows

Moving Rows

Bronze Challenge: Renaming the Delete Button

Silver Challenge: Preventing Reordering

Gold Challenge: Really Preventing Reordering

10. UINavigationController

UINavigationController

An Additional UIViewController

Navigating with UINavigationController

Pushing view controllers

Passing data between view controllers

Appearing and disappearing views

UINavigationBar

Bronze Challenge: Displaying a Number Pad

Silver Challenge: Dismissing a Number Pad

Gold Challenge: Pushing More View Controllers

11. Camera

Displaying Images and UIImageView

Adding a camera button

Taking Pictures and UIImagePickerController

Setting the image picker’s sourceType

Setting the image picker’s delegate

Presenting the image picker modally

Saving the image

Creating BNRImageStore

NSDictionary

Creating and Using Keys

Wrapping up BNRImageStore

Dismissing the Keyboard

Bronze Challenge: Editing an Image

Silver Challenge: Removing an Image

Gold Challenge: Camera Overlay

For the More Curious: Navigating Implementation Files

#pragma mark

For the More Curious: Recording Video

12. Touch Events and UIResponder

Touch Events

Creating the TouchTracker Application

Drawing with BNRDrawView

Turning Touches into Lines

Handling multiple touches

Bronze Challenge: Saving and Loading

Silver Challenge: Colors

Gold Challenge: Circles

For the More Curious: The Responder Chain

For the More Curious: UIControl

13. UIGestureRecognizer and UIMenuController

UIGestureRecognizer Subclasses

Detecting Taps with UITapGestureRecognizer

Multiple Gesture Recognizers

UIMenuController

UILongPressGestureRecognizer

UIPanGestureRecognizer and Simultaneous Recognizers

For the More Curious: UIMenuController and UIResponderStandardEditActions

For the More Curious: More on UIGestureRecognizer

Silver Challenge: Mysterious Lines

Gold Challenge: Speed and Size

Mega-Gold Challenge: Colors

14. Debugging Tools

Gauges

Instruments

Allocations instrument

Time Profiler instrument

Leaks instrument

Static Analyzer

Projects, Targets, and Build Settings

Build configurations

Changing a build setting

15. Introduction to Auto Layout

Universalizing Homepwner

The Auto Layout System

Alignment rectangle and layout attributes

Constraints

Adding Constraints in Interface Builder

Adding more constraints

Adding even more constraints

Priorities

Debugging Constraints

Ambiguous layout

Unsatisfiable constraints

Misplaced views

Bronze Challenge: Practice Makes Perfect

Silver Challenge: Universalize Quiz

For the More Curious: Debugging Using the Auto Layout Trace

For the More Curious: Multiple XIB Files

16. Auto Layout: Programmatic Constraints

Visual Format Language

Creating Constraints

Adding Constraints

Intrinsic Content Size

The Other Way

For the More Curious: NSAutoresizingMaskLayoutConstraint

17. Autorotation, Popover Controllers, and Modal View Controllers

Autorotation

Rotation Notification

UIPopoverController

More Modal View Controllers

Dismissing modal view controllers

Modal view controller styles

Completion blocks

Modal view controller transitions

Thread-Safe Singletons

Bronze Challenge: Another Thread-Safe Singleton

Gold Challenge: Popover Appearance

For the More Curious: Bitmasks

For the More Curious: View Controller Relationships

Parent-child relationships

Presenting-presenter relationships

Inter-family relationships

18. Saving, Loading, and Application States

Archiving

Application Sandbox

Constructing a file path

NSKeyedArchiver and NSKeyedUnarchiver

Application States and Transitions

Writing to the Filesystem with NSData

NSNotificationCenter and Low-Memory Warnings

More on NSNotificationCenter

Model-View-Controller-Store Design Pattern

Bronze Challenge: PNG

For the More Curious: Application State Transitions

For the More Curious: Reading and Writing to the Filesystem

For the More Curious: The Application Bundle

19. Subclassing UITableViewCell

Creating BNRItemCell

Configuring a UITableViewCell subclass’s interface

Exposing the properties of BNRItemCell

Using BNRItemCell

Constraints for BNRItemCell

Image Manipulation

Relaying Actions from UITableViewCells

Adding a block to the cell subclass

Presenting the image in a popover controller

Variable Capturing

Bronze Challenge: Color Coding

Gold Challenge: Zooming

For the More Curious: UICollectionView

20. Dynamic Type

Using Preferred Fonts

Responding to User Changes

Updating Auto Layout

Content Hugging and Compression Resistance Priorities revisited

Determining the User’s Preferred Text Size

Updating BNRItemCell

Constraint outlets

Placeholder constraints

21. Web Services and UIWebView

Web Services

Starting the Nerdfeed application

NSURL, NSURLRequest, NSURLSession, and NSURLSessionTask

Formatting URLs and requests

Working with NSURLSession

JSON data

Parsing JSON data

The main thread

UIWebView

Credentials

Silver Challenge: More UIWebView

Gold Challenge: Upcoming Courses

For the More Curious: The Request Body

22. UISplitViewController

Splitting Up Nerdfeed

Displaying the Master View Controller in Portrait Mode

Universalizing Nerdfeed

23. Core Data

Object-Relational Mapping

Moving Homepwner to Core Data

The model file

NSManagedObject and subclasses

Updating BNRItemStore

Adding BNRAssetTypes to Homepwner

More About SQL

Faults

Trade-offs of Persistence Mechanisms

Bronze Challenge: Assets on the iPad

Silver Challenge: New Asset Types

Gold Challenge: Showing Assets of a Type

24. State Restoration

How State Restoration Works

Opting In to State Restoration

Restoration Identifiers and Classes

State Restoration Life Cycle

Restoring View Controllers

Encoding Relevant Data

Saving View States

Silver Challenge: Another Application

For the More Curious: Controlling Snapshots

25. Localization

Internationalization Using NSNumberFormat

Localizing Resources

NSLocalizedString() and Strings Tables

Bronze Challenge: Another Localization

For the More Curious: NSBundle’s Role in Internationalization

For the More Curious: Localizing XIB files without Base Internationalization

26. NSUserDefaults

NSUserDefaults

Register the factory settings

Read a preference

Change a preference

Settings Bundle

Editing the Root.plist

Localized Root.strings

27. Controlling Animations

Basic Animations

Timing functions

Keyframe Animations

Animation Completion

Spring Animations

Silver Challenge: Improved Quiz

28. UIStoryboard

Creating a Storyboard

UITableViewControllers in Storyboards

Segues

Enabling Color Changes

Passing Data Around

More on Storyboards

For the More Curious: State Restoration

29. Afterword

What to do Next

Shameless Plugs

Index

More From Big Nerd Ranch...

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset