iOS Programming: The Big Nerd Ranch Guide, 3/e (Big Nerd Ranch Guides)

Read iOS Programming: The Big Nerd Ranch Guide, 3/e (Big Nerd Ranch Guides) Online

Authors: Aaron Hillegass,Joe Conway

Tags: #COM051370, #Big Nerd Ranch Guides, #iPhone / iPad Programming

BOOK: iOS Programming: The Big Nerd Ranch Guide, 3/e (Big Nerd Ranch Guides)
12.94Mb size Format: txt, pdf, ePub
iOS Programming: The Big Nerd Ranch Guide
Joe
Conway
and
Aaron
Hillegass

Copyright © 2012 Big Nerd Ranch, Inc.

 

All rights reserved. Printed in the United States of America. This publication is protected by copyright, and permission must be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permissions, contact

 

Big Nerd Ranch, Inc.
154 Krog Street
Suite 100
Atlanta, GA 30307
(404) 478-9005
http://www.bignerdranch.com/
[email protected]

 
 

The 10-gallon hat with propeller logo is a trademark of Big Nerd Ranch, Inc.

 

Exclusive worldwide distribution of the English edition of this book by

 

Pearson Technology Group
800 East 96th Street
Indianapolis, IN 46240 USA
http://www.informit.com

 
 

The authors and publisher have taken care in writing and printing this book but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein.

 

App Store, Apple, Cocoa, Cocoa Touch, Finder, Instruments, iCloud, iPad, iPhone, iPod, iPod touch, iTunes, Keychain, Mac, Mac OS, Multi-Touch, Objective-C, OS X, Quartz, Retina, Safari, and Xcode are trademarks of Apple, Inc., registered in the U.S. and other countries.

 

Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals.

 

 

 
Print ISBN-10  0321821521
Print ISBN-13  978-0321821522

Third edition, first printing, March 2012
Release K.3.1.1

 
Acknowledgments

While our names appear on the cover, many people helped make this book a reality. We would like to take this chance to thank them.

 
  • The other instructors who teach the iOS Bootcamp fed us with a never-ending stream of suggestions and corrections. They are Scott Ritchie, Brian Hardy, Mikey Ward, Christian Keur, Alex Silverman, Owen Matthews, Brian Turner, Juan Pablo Claude, and Bolot Kerimbaev.
 
  • Our tireless editor, Susan Loper, took our distracted mumblings and made them into readable prose.
 
  • Our technical reviewers, Bill Monk and Jawwad Ahmad, helped us find and fix flaws.
 
  • Ellie Volckhausen designed the cover. (The photo is of the bottom bracket of a bicycle frame.)
 
  • Chris Loper at IntelligentEnglish.com designed and produced the print book and the EPUB and Kindle versions.
 
  • The amazing team at Pearson Technology Group patiently guided us through the business end of book publishing.

The final and most important thanks goes to our students whose questions inspired us to write this book and whose frustrations inspired us to make it clear and comprehensible.

 
Table of Contents
Prerequisites
What’s Changed in the Third 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
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
Objects
Using Instances
Creating objects
Sending messages
Destroying objects
Beginning RandomPossessions
Creating strings
Format strings
NSArray and NSMutableArray
Subclassing an Objective-C Class
Creating an NSObject subclass
Instance variables
Accessor methods
Instance methods
Initializers
Other initializers and the initializer chain
Using Initializers
Class methods
Testing your subclass
Exceptions and Unrecognized Selectors
Fast Enumeration
Challenges
Bronze Challenge: Bug Finding
Silver Challenge: Another initializer
Gold Challenge: Another Class
Are You More Curious?
For the More Curious: Class Names
The Heap
The Stack
Pointer Variables and Object Ownership
Memory Management
Using ARC for memory management
How objects lose owners
Strong and Weak References
Properties
Declaring properties
Synthesizing properties
Instance variables and properties
Copying
Dot Syntax
For the More Curious: Autorelease Pool and ARC History
Projects, Targets, and Frameworks
Core Location
Receiving updates from CLLocationManager
Delegation
Protocols
Delegation, controllers, and memory management
Using the Debugger
Using breakpoints
Diagnosing crashes and exceptions
Bronze Challenge: Distance Filter
Silver Challenge: Heading
For the More Curious: Build Phases, Compiler Errors, and Linker Errors
Preprocessing
Compiling
Linking
Object Diagrams
MapKit Framework
Interface Properties
Being a MapView Delegate
Using the documentation
Your own MKAnnotation
Tagging locations
Putting the pieces together
Bronze Challenge: Map Type
Silver Challenge: Changing the Map Type
Gold Challenge: Annotation Extras
Views and the View Hierarchy
Creating a Custom View
The drawRect: Method
Core Graphics
UIKit Drawing Additions
Redrawing Views
Motion Events
Using UIScrollView
Panning and paging
Zooming
Hiding the Status Bar
Bronze Challenge: Colors
Silver Challenge: Shapes
Gold Challenge: Another View and Curves
UIViewController
Creating HypnoTime
Subclassing UIViewController
Another UIViewController
UITabBarController
View Controller Lifecycle
Initializing view controllers
UIViewController and lazy loading
View Controller Subclasses and Templates
Bronze Challenge: Another Tab
Silver Challenge: Controller Logic
For the More Curious: The main Function and UIApplication
For the More Curious: Retina Display
Notification Center
UIDevice Notifications
Autorotation
Setting autoresizing masks programmatically and bitwise operations
Forcing Landscape Mode
Bronze Challenge: Proximity Notifications
Silver Challenge: Programmatically Setting Autoresizing Masks
Gold Challenge: Overriding Autorotation
For the More Curious: Overriding Autorotation
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
Editing Mode
Adding Rows
Deleting Rows
Moving Rows
Bronze Challenge: Renaming the Delete Button
Silver Challenge: Preventing Reordering
Gold Challenge: Really Preventing Reordering
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

Other books

Denial by Keith Ablow
Homunculus by James P. Blaylock
Yearnings: A Paranormal Romance Box Set by Scott, Amber, McCray, Carolyn
Bombshell by James Reich
The Whiskered Spy by Nic Saint
Down in the City by Elizabeth Harrower
One Night of Scandal by Nicola Cornick