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
Bronze Challenge: Finding the Subforum
Silver Challenge: Swapping the Master Button
Silver Challenge: Processing the Reply
Gold Challenge: Showing Threads
Blocks and Block Syntax
Declaring block variablesDefining block literalsExecuting blocksMore notes about blocks
Basics of Using Blocks
Variable Capturing
Typical Block Usage
For the More Curious: The __block Modifier, Abbreviated Syntax, and Memory
For the More Curious: Pros and Cons of Callback Options
The Need for Stores
Creating BNRFeedStore
Using the Store
Building BNRFeedStore
Initiating the connectionAnother request
JSON Serialization
More on Store Objects
Bronze Challenge: UI for Song Count
Mega-Gold Challenge: Another Web Service
For the More Curious: JSON Data
Caching the RSS Feed
Advanced Caching
NSCopyingFinishing the BNR feed
Read and Unread Items
Other Benefits of Store Objects
Bronze Challenge: Pruning the Cache
Silver Challenge: Favorites
Gold Challenge: JSON Caching
For the More Curious: Designing a Store Object
Determining external sourcesDetermining singleton statusDetermining how to deliver results
For the More Curious: Automatic Caching and Cache.db
iCloud Requirements
Ubiquity Containers
Provisioning a Ubiquity Container
Core Data and iCloud
For the More Curious: iCloud Backups
What to do next
Shameless plugs
An aspiring iOS developer faces three basic hurdles:
We have used this material many times at our iOS Development Bootcamp at Big Nerd Ranch. It is well-tested and has helped hundreds of people become iOS application developers. We sincerely hope that it proves useful to you.
This book assumes that you are already motivated to learn to write iOS apps. We won’t spend any time convincing you that the iPhone, the iPad, and the iPod touch are compelling pieces of technology.
We also assume that you know the C programming language and something about object-oriented programming. If this is not true, you should probably start with an introductory book on C and Objective-C, such as
Objective-C Programming: The Big Nerd Ranch Guide
.
This edition assumes that the reader is using
Xcode 4.3
and running applications on an iOS 5 device or simulator.
With iOS 5, automatic reference counting (ARC) is the default memory management for iOS. We’ve redone the memory management chapter to address ARC, and we use ARC throughout the book.
You’ll find new chapters on using gesture recognizers, storyboards,
NSRegularExpression
, and iCloud. We’ve also added two chapters dedicated to the the Model-View-Controller-Store design pattern, which we use at Big Nerd Ranch and believe is well-suited for many iOS applications.
Besides these obvious changes, we made thousands of tiny improvements that were inspired by questions from our readers and our students. Every page of this book is just a little better than the corresponding page from the second edition.
This book will teach you the essential concepts of iOS programming. At the same time, you’ll type in a lot of code and build a bunch of applications. By the end of the book, you’ll have knowledge
and
experience. However, all the knowledge shouldn’t (and, in this book, won’t) come first. That’s sort of the traditional way we’ve all come to know and hate. Instead, we take a learn-while-doing approach. Development concepts and actual coding go together.
Here’s what we’ve learned over the years of teaching iOS programming:
What does this mean for you, the reader? To learn this way takes some trust. And we appreciate yours. It also takes patience. As we lead you through these chapters, we will try to keep you comfortable and tell you what’s happening. However, there will be times when you’ll have to take our word for it. (If you think this will bug you, keep reading – we’ve got some ideas that might help.) Don’t get discouraged if you run across a concept that you don’t understand right away. Remember that we’re intentionally
not
providing all the knowledge you will ever need all at once. If a concept seems unclear, we will likely discuss it in more detail later when it becomes necessary. And some things that aren’t clear at the beginning will suddenly make sense when you implement them the first (or the twelfth) time.
People learn differently. It’s possible that you will love how we hand out concepts on an as-needed basis. It’s also possible that you’ll find it frustrating. In case of the latter, here are some options:
This book is based on the class we teach at Big Nerd Ranch. As such, it was designed to be consumed in a certain manner.
Set yourself a reasonable goal, like
“
I will do one chapter every day.
”
When you sit down to attack a chapter, find a quiet place where you won’t be interrupted for at least an hour. Shut down your email, your Twitter client, and your chat program. This is not a time for multi-tasking; you will need to concentrate.
Do the actual programming. You can read through a chapter first, if you’d like. But the real learning comes when you sit down and code as you go. You will not really understand the idea until you have written a program that uses it and, perhaps more importantly, debugged that program.
A couple of the exercises require supporting files. For example, in the first chapter you will need an icon for your Quiz application, and we have one for you. You can download the resources and solutions to the exercises from
http://www.bignerdranch.com/solutions/iOSProgramming3ed.zip
.
There are two types of learning. When you learn about the Civil War, you are simply adding details to a scaffolding of ideas that you already understand. This is what we will call
“
Easy Learning
”
. Yes, learning about the Civil War can take a long time, but you are seldom flummoxed by it. Learning iOS programming, on the other hand, is
“
Hard Learning,
”
and you may find yourself quite baffled at times, especially in the first few days. In writing this book, we have tried to create an experience that will ease you over the bumps in the learning curve. Here are two things you can do to make the journey easier:
If you’re reading this book on a Kindle, KindleFire, or Kindle for iPad, we want to point out that reading the code may be tricky at times. Longer lines of code will wrap to a second line based on the current font size. This bothers us because we’re really conscientious at Big Nerd Ranch about the way our code appears on the page. Clear visual patterns in code make code easier to understand.
When you get to the point where you’re actually typing in code, we suggest opening the book on your Mac in Kindle for Mac, a free application you can download from Amazon.com. Make the application window large enough that you can see the code with no wrapping lines. You will also be able to see the figures in full detail.
The longest lines of code in this book are 86 monospace characters. Use the following sample to see how your Kindle application or device displays them.
You can play with the settings in your Kindle application or device to find the best ones for viewing long code lines. Here are some suggestions for reading on the various devices:
To see the code with no wrapping, hold the device in landscape mode, touch the
Aa
icon, select either of the two smallest fonts in the top section, and select the single-column icon in the bottom section.
On the Kindle E-Ink devices, there is a bug in how strikethrough is rendered. (We use strikethrough to indicate that a line of code should be deleted.) The first word of a line may not get struck through. So be extra careful if you are typing in the code while reading the book on an E-Ink device. Again, we suggest using Kindle for Mac when typing in code.