IOS development late start

Apple stock is falling on the news that iPhone 5 sales are expected to be down 40% below projections. Without Steve Jobs at the helm, it was only a matter of time before this sort of thing happened.

Screen Shot 2013-01-15 at 3.52.47 PM

It seems like a great time for me to finally get started learning IOS development. One part of the impetus comes from my work at Ancestry.com where I’m working to development better software testing practices — which happens to include for IOS. And the other part comes from my own project (currently on hold) to develop a mobile app.

Screen Shot 2013-01-15 at 3.59.59 PM

I started Budgeteer last year while I was in Ecuador using Sencha Touch for the UI which takes Javascript and HTML5 and compiles it to a native app. (I also happened to be consulting for Sencha at the time.) Since I’m working in IOS now, I thought I’d take up the project again as a native app. I’m also interested in Xamarin (by the guys who gave you Mono) to build cross platform apps in C#, but that’ll have to wait. I was burned before with Titanium.

I feel like I’m getting a late start in IOS development, but that’s OK. There have been some good developments lately that make it much easier including storyboards, automatic memory management, and UIAutomation. Which are great, but there is still a lot of code out there that doesn’t take advantage of it all, and much of the information you’ll find online is out of date.

I’ll try to address this and would appreciate any comments that can correct me.

First off, you’ll need a Macintosh computer. Apple has decreed that you need to use their tools (and while there are ways around it — like the aforementioned Sencha Touch, Titanium Appcelerator, Xamarin, etc. — they’re still not as mature and are all proprietary.)

And then you’ll need XCode. That’s the Apple IDE. It’s kindof ok. Not a great productivity booster, but at least it’s free now. Download it from the app store (iTunes). That’s right, Apple thinks a software development platform is an MP3.

I’m going to start with a simple Hello world to get you up and running in IOS. And then I’m going to build an adventure game based on a popular movie franchise.

I’m using XCode 4.5 (which is quite different from XCode 4-4.2 which is a total change from XCode 3) so screenshots and UI directions might get quickly out of date.

Once you’ve installed XCode, create a new project, and since we’re doing this for iPhone app-love let’s create an IOS application.

From the toolbar click “File -> New -> Project”. Choose an application template. IOS -> Application -> Single View Application (we’re not too ambitious.)

Screen Shot 2013-01-15 at 4.26.09 PM

Enter your project information and click next.

Screen Shot 2013-01-15 at 4.28.01 PM

Take a look at your project in XCode and notice the files on the left hand side

Screen Shot 2013-01-15 at 4.32.50 PM

You have the the folling files:

SWAppDelegate.h
SWAppDelegate.m
MainStoryboard_iPhone.storyboard
MainStoryboard_iPad.storyboard
SWViewController.h
SWViewController.m

The .h files are interface files (think “like C headers” but not too hard.)
The .m files are implementation files (think “like .c files” but not really.)
The .storyboard is your user interface.

Click on MainStroyboard_iPhone.storyboard and it brings up the Interface Builder. Which shows a picture of an iPhone screen.

Screen Shot 2013-01-15 at 4.38.59 PM

Look in the lower right corder. You see “Objects” with “View Controller” highlighed. Remember selecting “Single View” in the template. This is what you get. Another common View Controller is the “Table View Controller” and I’ll let you guess what that does. A basic ViewController is what we have SWViewController is it.

You can see it the source code by clicking on SWViewController.m and if you click on the toolbar: View -> Assistant Editor -> Show Assistant Editor or click on the theater mask (shirt with bowtie?) in the upper right corner of your screen you’ll see SWViewController.h right alongside it.

Screen Shot 2013-01-15 at 4.42.20 PM

Let’s just ignore the details of Objective-C for now. I don’t get it, and I’m going to explain it a in a little more detail in my next post. As far as I’m concerned Objective-C is esthetically the most objectionable programming language I’ve ever seen. And that includes a nightmare hybrid of Perl and BASIC.

But we want to see this thing do something, and compile, and run. So go back to your storyboard and where it says “Objects” in the lower right corner, click the dropdown and change it to “Controls”

Screen Shot 2013-01-15 at 4.48.37 PM

Then click and drag a label onto the storyboard.

Screen Shot 2013-01-15 at 4.51.38 PM

Change your label to say something interesting (not by doubleclicking) by clicking on the label, then clicking on the 4th icon in the top right (a seatbelt?) and editing the field under Text: Plain where it says “Label” to say something more interesting:

Screen Shot 2013-01-15 at 4.53.53 PM

Expand the label by dragging, and tweak the font size and color to your heart’s content. Come back when you’re done playing and then select “IPhone 6.0 Simulator” under “IOS Device” in the top left corner of XCode and click Run. After a couple minutes you’ll see first cool new iPhone app.

force

Congratulations. You’ve taken your first step into a larger world.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s