Whether you’re running for the hills after Adobe’s announcement, or just looking to broaden your skillset, Objective-C is a worthwhile investment to add to your portfolio. I love apps. My mom loves apps. Who doesn’t love apps? While I may not agree with a lot of he-who-shall-not-be-named‘s policies, Apple has something amazing going for it: All its products are remarkably synergetic. It’s something I’ve noticed way back when I got my first macbook and iPod, and it’s only gotten stronger since then. If you learn to master Objective-C, you will obtain a skillset that is as versatile as Apple’s product line (and once the iRefridgerator comes out, you’ll be ready to slap Angry Birds on it, as well).
Before We Begin
What you will need for these lessons:
- Snow Leopard or Newer OS
- Xcode 4.2 (Warning: This app is a beast. Make sure you’re not using your three year old macbook to develop with it.)
- Recommended: An iPhone and/or iPad and developer’s license.
Your New Friends
Setting up a Project
In this lesson we won’t actually write any code, just create a project and observe how the tools lay everything out for us. Let’s begin by opening up Xcode.
- The first thing you should notice is the Xcode welcome screen. Just click the Create a new Xcode project button to launch the wizard.
- At this point, you’ll see there are quite a few options for you to choose from, conveniently grouped by iOS and Mac OS X. under iOS, make sure Application is selected, then choose Master-Detail Application on the right side. Click Next.
- Now the wizard wants you to define the project. Set the Product Name to “Tutorial1,” the Company Identifier to whatever base package structure you want (in my case, I used my standard, “com.schelterstudios”). Set the Device Family to iPhone, and make sure only Use Automatic Reference Counting is checked. We’ll go over the rest of what these fields mean in a later lesson.
- Choose a folder to save your project in. (Xcode will create a folder with the name of the project for you, so just choose the parent folder for this step.)
At this point, your window should look like this:
Now, I’d first like to direct your attention to the View buttons in the top right corner of the editor. These show and hide the main view sections of Xcode. From left to right, you have Navigator, Debug and Utilities.
- Navigator - This view is for traversing throughout all the folders and files in your workspace. There are various tabs within the view to provide different ways you can drill down to the code you need to access.
- Debug - Basically does just what it sounds, this view shows you your traces and live variables.
- Utilities - Utilities handles everything else you need, such as configuration, documentation, and formatting while in code view, and component insertion and editing from the interface builder view.
The top center of the editor displays the running state of the application. This gives feedback on the linkage between Xcode and the Simulator or your device, and will also identify any build issues it may find. To the left of that is the Scheme. These drop-downs identify the scheme you are using when running your application. You can configure various schemes for different build routines, but that stuff gets pretty advance pretty fast. The right-side drop-down alone is sufficient for most projects, which is what you’d use to switch between testing via iPhone simulation, testing via iPad simulation, and testing on your device.
Finally, the top left has the Run and Stop buttons, which is what you’ll use to start and stop your build tests. If you hold down the Run button, you can also switch to Test, Profile and Analyze.
- Run - Runs the application in the simulator or on your device. This is the standard way to view your app.
- Test - Executes your unit tests.
- Profile - Runs the application and shortcuts you to the Instruments app.
- Analyze - A quick run-down by the editor to provide suggestions of possible leakages or other inefficiencies.
This is the extent of the lesson for now. At this point you can check out the application built so far by the Xcode wizard by making sure the Scheme is set to iPhone 5.0 Simulator and pressing the Run button. The iOS Simulator should pop up and display the screen below.
As you play around with it, you can see that the simulation lets you rotate, swipe, shake, hide the app, etc. It also comes with a few other apps that you can code your application to interact with, such as photos or contacts. Not too scary, right? In the next lesson, we’ll be covering the specifics of the files generated by the wizard, and Objective-C class structures. Also, feel free to leave feedback to let me know how you feel about the pacing of these lessons. My aim is to make migration as comfortable as possible, while also focusing on the specifics of each aspect of Xcode and Objective-C without ending up with a massive wall of text in a single post.
September 2014 M T W T F S S « May 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30