APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed

Basics of the iPhone/iPad SDK

I wrote my very first iPhone/iPad app today. Don't get excited, it's not even worth showing. What I want to talk about here is what confused me so that if you want to get started with this yourself, you might have a little less trouble than I did.

You can download the iPhone SDK from Apple. You do have to register as a developer, but that's free. If you actually end up making something you want to sell, that's going to cost you $99 a year at least, but you don't need to do that now.

You do need an Intel Mac running OS X and a few extra gig of space. Once you've got it all downloaded and installed, you are ready to start writing apps. Note that although it says "iPhone SDK", this can create apps for iPad and iTouch also.

You need at least a half-baked knowledge of Objective C++. Those of you who hate object oriented programming don't have to start cursing just yet - while iPod/iPhone programming certainly uses objects, you don't have to know all that much and can do quite a lot with standard C syntax. I'm mostly ambivalent myself; I can put up with it enough to do what I need to do.

Where I ran into confusion had nothing to do with any of that. Oh, sure, I mistyped object references, forgot some things entirely and even stuck stuff in the wrong files. But that wasn't anything that stopped me dead. No, my confusion was much more basic: I didn't understand how Interface Builder got connected to my code.

Now that I do understand a bit more, this kind of makes sense. The Interface Builder component has lots of pre-defined things like buttons and labels and you just drag them into your window or view. That's easy enough, and you connect them to code by drawing a line between the code and the object. The code has to be in place before you can do that - you can drag all the buttons you want, but you can't connect them until you have code defined.

Window SDK Interface Builder SDK

If you are working with a sample app (and there are many to be found), it helps to have the 10,000 foot view: you are going to pick a template when you start a new project. That template is going to create at least one NIB file (that's the MainWindow.xib file shown below) and at least one each of an *AppDelegate.h and an *AppDelegate.m file. Double-clicking on the NIB file will bring up Interface Builder where you can drop buttons and all that. Back in those Delegate files is where you'll be putting definitions and code.

Interface Builder SDK

You link inputs and outputs in Interface Builder. For example, I control-clicked on my Button and dragged the line to the Application Delegate icon. A little window opens up showing the methods that I defined in the h and .m files. If I tried to do this before defining any methods (of course I did exactly that) or if you've made some silly mistake defining your methods (yes, I did that more than once), you won't get the window.

Once you do have everything correct and connected, clicking Build and Run fires up the Emulator - either iPhone or iPad, depending on what you originally said you were going to develop. You see what it looks like and your controls will do what you told them to do. You can also use these emulators to go see what your web pages look like on these devices; of course I did that before I did anything that worked at all.

So - the major confusion here was just not understanding how to get stuff brought in through Interface Builder connected to code. Everything else is just syntax and convention first and plain old programming after that. Apple has tremendous mountains of videos, web pages and lectures about basic and more advanced subjects - it will be a long time before I'll even understand a small percentage, but at least now I grok enough to actually start lurching about knocking things over. I'm happy with that for now.



Got something to add? Send me email.





(OLDER)    <- More Stuff -> (NEWER)    (NEWEST)   

Printer Friendly Version

-> -> Getting started with the iPhone SDK (Software Development Kit)

3 comments



Increase ad revenue 50-250% with Ezoic


More Articles by

Find me on Google+

© Anthony Lawrence







Mon Apr 5 22:40:50 2010: 8372   DaleReagan

gravatar


Hey Tony,

Tried any of the 'write once - deploy many' solutions? I've read rumblings of vendor-supported solutions (i.e. mobile manufacturer supported dev environments) and took a look at: (link) (blog post at: (link) .) Some interesting options. Note: my test-apps are not real apps - just explorations of the process/tools...

:)
Dale



Tue Apr 6 01:10:10 2010: 8373   TonyLawrence

gravatar


I have looked at a few, yes, but haven't seen anything that caught me.



Wed Apr 7 11:04:59 2010: 8378   TonyLawrence

gravatar


Another silly mistake I made was not to Save after making changes in Interface Builder. This gave me a few hours of needless frustration. When you click Build and Run back in Xcode, you will be warned if you have unchanged edits in your code, but not if you didn't save the IFB changes.

My learning path is much smoother after realizing that :-)





------------------------
Kerio Samepage


Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us





I wanted to learn how to swim, so Google showed me how to turn on the water at the sink and let me splash it around a bit. They then dragged me into a helicopter, flew way out into the ocean and dumped me out. (Tony Lawrence)





This post tagged: