Preliminaries
This introductory chapter aims to make sure you have all the required tools and accessories to proceed with full confidence.
Three types of readers are likely to read this book. One group can skip to Chapter 2 immediately without reading Chapter 1. Another group may only need to read one small section in Chapter 1 before moving on to Chapter 2. The third group should read Chapter 1 very carefully before moving on.
In order to program for the iPhone and/or iPad, and to follow along with the exercises, tutorials, and examples presented in this book, you’ll need to meet six minimal requirements. You may not completely understand these requirements right now, but that’s okay—just roll with me for a second, and I’ll explain everything as we go through these steps.
Note Whenever I say iPhone or iPad, I’m referring to any iPhone or iPad OS device, including the iPod touch. And when I say Macintosh HD, yours may be named something different.
Briefly, you’ll need six things:
Let’s go into each of these in a bit more detail.
Getting a Mac
As far as your Mac is concerned, I’ll explain what you need in two ways—first a geeky way and then a newbie way.
All the videos on the net that accompany this book are screencast from my MacBook Pro, bought in 2011; if I broadcast from my 2010 iMac, I first run the app on my MacBook Pro, bought in 2011.
You don’t need the latest revved-up Mac. If you haven’t bought one yet, get a basic, no-frills MacBook Air. See Figure 1-1.
Figure 1-1. The author uses the cheapest 2011 MacBook Pro on the market to perform all the coding and compiling in this book. Many of the authors’ students purchase the MacBook Air for $999, as illustrated here
Or buy a secondhand MacBook Pro on eBay or another such site. If you do that, or own an older Mac, you may be able to add some RAM. I suggest you make a free appointment at the nearest Apple Store’s Genius Bar and ask whether they can increase the RAM on your older model Mac. If so, ask about the maximum the RAM can be increased. Then ask explicitly: “Can this old computer run Mountain Lion, at least 10.8.1, and Xcode 4.4.1 or later?”
If you don’t have a Mac, you’ll need to buy one if you want to follow along with this book or program Objective-C to create iPhone apps. Keep in mind that, as mentioned, I’ve made a point to code and run every program in this book on Apple’s smallest and cheapest model, the MacBook Air—many of my newbie students buy the MacBook Air for $999.
You’ll need the correct version of OS X. At the time of this writing, that version is OS X 10.8.1. You need to have the latest greatest operating system inside your Mac. I see a lot of emails and forum questions revealing that many people think: “Ah, my code probably didn’t compile correctly because Dr. Lewis has a different version of OS X or/and iOS on his machine…”
Note Even if you think your system is up-to-date, I suggest you follow along in this section to make sure your system has the latest OS X and the latest iOS inside it. I say this because as you follow along in this book and tackle all the programs, there will be times when your code doesn’t work the first time you run it.
To make sure your system is recent enough to follow along with the book, please do the following:
Figure 1-2. Here you can see that Dr. Lewis’s iMac is using OS X 10.8.1. and Xcode 4.4.1
Now make sure your Mac has the latest software:
Figure 1-3. Top: Checking for new software. Middle: Download any new software and wait for software to download. Bottom: All software updated.
If your version of OS X or iOS makes my pictures seemed dated, don’t freak out. Along with volunteers, I maintain a forum that has news about recent updates of OS X and iOS. You can visit the forum at www.rorylewis.com/ipad_forum/.
Becoming a Developer
If you’re not already one, you need to become a registered developer via the iPhone/iPad DK for $99. Or you can get an introductory set of bells and whistles for free.
Making Your Choice
If you’re a student, your professor has probably already taken care of this, and you may already be registered under your professor’s name. If you’re not a student, you need to decide which type of developer you’d like to be. Here are your options:
Let’s get started installing Xcode.
Figure 1-4. Click the Enroll Now button
Figure 1-5. Click the Continue button
Figure 1-6. Click the “Create an Apple ID” option to proceed
Figure 1-7. Click the Individual option
Figure 1-8. Enter all your information accordingly
Note Before you move on to step 6, make sure you have received your confirmation email and chosen a password to complete the last step of getting set up as a bona fide registered Apple developer. Congratulations!
Figure 1-9. For now click the iOS Dev Center icon as indicated by the arrow. Later you may want to program applications for Mac computers or the Safari web browser
Figure 1-10. The Downloads link takes you to the bottom of the page
Note At the time of writing, Xcode 4.4 and iOS SDK 6 are the latest environments. By the time you read this book these may well have larger numbers. That’s not a problem—just go on to step 8. If by chance something has really thrown us a curve ball, it will be discussed and solved for you in our forum located at www.rorylewis.com/ipad_forum/ or http://bit.ly/oLVwpY.
Figure 1-11. Clicking the Download Xcode 4 button takes you to the Xcode 4 Developer page
Figure 1-12. Click the View in Mac App Store button
Figure 1-13. Click Install and wait for the download to complete
With your Xcode and iPhone/iPad Simulator tools installed and ready to access easily, you’re almost ready to roll.
ABOUT DEMOMONKEY
Before you load the final tool—called DemoMonkey—let’s step back and have a look at where you’re going.
Through the years I’ve found that the most efficient way to teach students code is to take what I call the subsystem approach, teaching which pieces or sections of code will serve you in which situations. In this book I use a cool program you may have seen if you watched the latest WWDC: DemoMonkey. Essentially, in DemoMonkey you drag a heading explaining what needs to be done from the DemoMonkey palette. As you drop it into your code at the appropriate section of your Xcode file, it magically transforms into code that the author of the DemoMonkey file wrote. Before you can download and compile the Xcode project that creates DemoMonkey, you need to make sure Xcode works. So in the next section you first run a simple app to make sure all is in order in Xcode land.
Getting Ready for Your First iPhone/iPad Project
Before starting on your first app, you need to make sure that everything runs. Assuming you’ve already downloaded and installed Xcode, open it up:
Figure 1-14. Select the Single View Application and then click Next
Figure 1-15. Let’s go for a test drive
Note This test doesn’t use Storyboards. I just want you to see that Xcode builds a simple app. So keep everything unchecked—yes, including “Use Storyboard”—for now (as shown in Figure 1-15).
Figure 1-16. The initial Integrated Development Environment (IDE)
Figure 1-17. Your first test drive
Congratulations! You’ve loaded Xcode and have taken it for a test drive. Now let’s get DemoMonkey running and start your first app.
Installing DemoMonkey
DemoMonkey is an optional tool intended to help you follow along with the book’s projects. You only need it if you choose to use our .demoMonkey files for each chapter, which will allow you to drag and drop ready-to-use code snippets into the Xcode for most of the steps. If you don’t want to do that, you can still type the code yourself, and if you choose not to use DemoMonkey for this book, you can skip the rest of this chapter.
DemoMonkey will make life easier for you by letting you focus more on the code you’re using—but you’ll still be challenged in this book. That’s simply part of my pedagogy. The issue is really how to handle things when you get challenged.
Note When you find yourself in a tough spot, you can always reread the section, rewind the video examples, or—most importantly—visit the forum where you’ll often find many people, including me, online and ready to help you immediately. We may refer you to somebody else’s solution or we may help you directly. So go to the forum, say hello to the crowd, and become immersed by first seeking help from others and then going back to help others. The forum is at www.rorylewis.com/ipad_forum/ or http://bit.ly/oLVwpY .
With your Xcode running and building apps, you can now install DemoMonkey:
Figure 1-18. Download Sample Code
Figure 1-19. Open the DemoMonkey Xcode project inside your DemoMonkey folder
Figure 1-20. Expand the Project Navigator and choose Show in Finder from the context menu
Figure 1-21. Drag the DemoMonkey.app to your Applications folder
Note If for some reason you were unable to reproduce the steps in this section, you can download a compiled DemoMonkey.app from my site using this link: http://bit.ly/RpCtFj. Then simply drag it to your Applications folder.
You’re ready to roll now!