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.
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.
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
Increase ad revenue 50-250% with Ezoic