iPhone Development for Beginners – 2010 Edition

So you want to learn iPhone development. Good for you! It’s an exciting platform with great developer tools and an outstanding community. Let me tell you a bit about the benefits of building an app the right way and show you some great resources to get started.

The most important point: If you want a great application with a user experience you’ll be proud of, build a native application using Apple-blessed developer tools and resources. Apple’s developer tools are outstanding applications and the iPhone frameworks provide useful, battle-tested, mature code that lets you do a lot without reinventing the wheel every time you need to build even basic functionality. Best of all, Apple gives their tools away for free.

Don’t screw around with stuff like PhoneGap or Adobe’s Flash-to-iPhone binary whatsit just because it might be a little closer to your comfort zone. You’ll risk writing an application with a library that gets left in the dust when Apple releases a new version of the SDK with great new features. You’ll also risk having your application rejected if Apple decides one morning that the tools you used are accessing private methods, running interpreted code or disrespecting some other element of the SDK agreement. Finally, you’re not going to be working with the same design vocabulary expressed by every popular iPhone application.

With UIKit, Apple hands you an enormous pile of outstanding interface classes that are exceptionally clever, attractive and versatile. They’re yours to build with and do as you please. Thousands of hours of interface coding that you don’t have to do, saving you time and allowing you to write an app with an experience that’s consistent with everything your users will expect on the iPhone.

With Core Data, you get a powerful object modeling framework with built-in persistence. What does that get you? If you’re building an application, you’ve got data. Lots and lots of data, sometimes. You’re going to need a way to define and encapsulate that data so that you can keep track of relationships between different chunks, pass information around the application and store it for later use. This can be tedious, laborious, time-consuming work. Core Data does all of the heavy lifting for you.

For me, those are the biggest freebies you get with approaching iPhone development “the right way.” That barely scratches the surface, though, since Apple provides powerful APIs that let you accomplish drawing, manipulating the filesystem, performing network operations, dead-simple threading, and many other useful things.

Hopefully you’re intrigued. You’ll need to be, especially if you’re starting from scratch. There’s a big chunk of learning you’ll have to do. It’s worth it, though. The iPhone is a really fun platform and there’s something potent about developing for a mobile device that’s always in your pocket.

Find the section that describes you below and proceed from there for my advice on great learning resources.

You’ve never coded anything, ever (or, C-based languages scare you)

Let’s start with C. C is a venerable language with a long history, born in 1972. C is important background to have for iPhone development, since so many Apple APIs use either C or Objective-C, a related language we’ll talk about next.

Luckily, Dave Mark has you covered. Learn C on the Mac assumes no pre-existing experience with any programming language. You’ll get a friendly explanation of everything you need to understand C and the basics of programming. This is ground zero, indispensable knowledge for anyone who is approaching this with no experience. The best part is that Dave has written for someone who will be using Apple’s developer tools, so you’ll be getting a perspective that will be useful for your iPhone efforts a little bit later.

You’re comfortable with programming and C, but not Objective-C

Objective-C is built on top of C, so if you’ve got a basic comfort with programming in C, you’ll have an easy time getting up to speed. Objective-C lets you build object oriented code. Whuzzat? It’s Legos for programming. You can build your own bricks and trade them with friends. Put simply, object oriented programming (OOP) lets you build modular software that maximizes code reuse. Reusing code is good! Chances are, if you solve a problem once in your project, you’ll need that solution again later. OOP lets you easily package up these solutions and deploy them anywhere they’re needed in your code.

Confused? You won’t be after you read Learn Objective-C on the Mac. You’ll learn all the details of how Objective-C works. The book is packed with clear explanations of how to use object-oriented programming and practical exercises to get you comfortable with building useful code in Objective-C. You will not enjoy learning iPhone development without a solid foundation in Objective-C. You’ll get one here. Many lightbulbs will turn on for you.

You understand Objective-C but you’re not yet confident enough to build an app with it

If you feel great about Objective-C and you can’t wait to get started, go on to the next book. If you want to build a little more confidence, it might be worth spending some time practicing with Objective-C and how it interacts with Apple’s Cocoa API. What’s Cocoa? It’s a huge collection of pre-made building blocks you’ll use to build applications. (Not to be confused with Cocoa Touch, which is a version of Cocoa custom-tailored for the iPhone, which you’ll meet later.)

Cocoa Programming for Mac OS X is great introduction to Cocoa. You’ll learn about using Objective-C with Cocoa, use Interface Builder to construct some interfaces and walk through plenty of exercises. You even get to play with Core Data. By the first dozen chapters or so, you should be ready to rock. Many of the Cocoa goodies you play with on the desktop will be waiting for you on the iPhone.

You’re comfortable with programming and Objective-C

It’s time to get rolling with the iPhone.

I own several iPhone development books. None is a better, more useful introduction to developing for the platform than Beginning iPhone Development. It’s Dave Mark again, alongside Jeff LaMarche, with everything you need to get started. Beginning iPhone Development is a comprehensive exploration of building software for the iPhone. The authors provide friendly guidance as they break you in gently. You’ll learn how to construct interfaces, master table views, and how to store and load data, even using Core Data. The book is filled with useful, practical exercises that you’ll be able to use for your own projects. Dave and Jeff are great about providing code that is both understandable for learning and yet practical enough to serve as a springboard for solving your own problems in your own apps.

If you’re learning how to develop for the iPhone but you don’t have their book, you’re doing it wrong.

They don’t stop, there, either.

Jeff and Dave’s latest, More iPhone Development, is loaded with meaty chapters on advanced topics. My favorites: several chapters on Core Data (nearly half the book) and an outstanding tutorial on how to use Xcode’s debugging tools.

The breadth and depth of these titles together is unbeatable for a beginner iPhone developer. Between both books, you’ll have answers for most quandaries you’re likely to encounter in your early projects.

On teaching yourself

So how do you use these great learning tools? I’m a passionate, lifetime autodidact. Here’s my advice:

At least one hour, every single day.

The books I’ve described present their content split up into chapters. Read and work through at least one chapter per day. Don’t try to cram it all into a couple of weekends, skimming examples and reading exercises instead of trying them.

Even if you’re starting from the ground up, you can easily get through every single book I’ve described here within three or four months.

You’re setting up your own little school. Make a point of setting a time when your studies begin and end and make a habit of sticking to that schedule. If you have to miss a night of your programming school, give yourself some time to make up for it the next day.

Equipment

Get the PDF eBook editions of the books you need. You can never lose them, forget them at the office, spill coffee on them, whatever. They’re instantly searchable and much easier to work with in a nightly home school setting than paper books. They’re sometimes cheaper than paperbacks, you don’t pay shipping and you can get them instantly via the web. I have a blend of paperbacks and PDFs — I’m much happier with my PDFs, especially when traveling.

If you’re serious about programming, you’re going to need a second monitor as well, unless the one you already have is enormous. One day you’ll have real projects to work with, which means a debugger window, some documentation open at all times, and plenty of other clutter. A second display will make your life manageable. During your programming school, having a second display for your eBooks will make working through your exercises on the main monitor much easier.

Finally, you’ll need a notebook. As you work through books and exercises, make note of the important, central concepts and create lists of basic vocabulary. You’re going to have a lot of new knowledge to sift through. Make it easy on yourself by building your own cheat sheets to reference in the middle of exercises or when you make the jump to the next level of learning. It’s a lot easier to consult your own notes than try to figure out which book had which handy tip.

Start

Just get started. Pick a book, pick a time and start. It’ll be weird at first, especially if you’re new to programming. That’s okay. Wikipedia is close by with a wealth of technical articles on anything you might want to know about. If you have questions and don’t know who to ask, Stack Overflow is filled with knowledgeable (and not so knowledgeable) members who will be eager to point you in the right direction, no matter how specific or arcane the query.

Good luck! This is an exciting time to develop for mobile devices. The iPhone is the most potent and exciting handheld computer ever. You’re going to have a great time — once you get started.

(Note: Apress didn’t sponsor this post or anything but I notice they make up almost all of my recommendations. Kudos to them for hiring outstanding writers who care about relating their wisdom in a clear, enjoyable manner. Their books have great layout and intelligent structure, so they work as well for reference as they do for sequential, hands-on learning. Truly a great publisher who understands the needs of its audience.)

Comments

  1. Roger Collins January 21st

    Comment Arrow

    Well said. Never thought about .pdf books. I know many times I wish I could have cut and pasted code from my old fashioned paper books. Do the .pdf versions support that?


  2. Danilo Campos January 21st

    Comment Arrow

    Good point, Roger. Forgot entirely to mention that. Yeah, you can definitely copy a block of code from a PDF eBook into Xcode.

    On a first run-through, I find it more useful to hand-type whatever code is in an exercise. Afterward, if harvesting something useful to add to an existing project, being able to copy/paste is really handy.


  3. paul_sns January 21st

    Comment Arrow

    Nice walkthrough of iPhone development resources. I saw another book for Programming in Objective-C 2.0 by Kochan in Amazon which had great reviews, would you also recommend that?

    I would also like to suggest going to iTunes U and subscribing to the Stanford iPhone Applications Programming class. That’s also one very useful resource indeed.

    Thanks.


  4. Brian LeRoux January 22nd

    Comment Arrow

    To be clear: PhoneGap is Apple approved as of 0.8.0, they reviewed the code and it only uses public api calls. And Apple will not be deprecating their own SDK anytime soon / it would eviscerate the (obviously wildly profitable) App Store marketplace.

    The purpose of PhoneGap is to be a cross platform mobile solution for iPhone, Blackberry, Android, Symbian and Palm; not just an ‘easier’ iPhone solution!

    All that said, I agree, its great to learn the base programming languages to get the most out of the platforms they target.


  5. Trey Campbell January 23rd

    Comment Arrow

    Nice introduction/overview, Danilo.

    Apress also has a deep discount on the eBook versions ($10) if you own the dead tree version. Like Roger said, I find it handy to be able to copy and paste code when I want to–worth $10 to me.

    Also, highly recommend Dave and Jeff’s books. I remember Dave’s Mac Programming Primer books from eons ago.


  6. Danilo Campos January 23rd

    Comment Arrow

    Brian,

    Thanks for the comment. While Apple has an engineering team specifically dedicated to ensure ongoing compatibility on new versions of iPhone OS with older frameworks, that doesn’t mean mean binaries compiled against those frameworks are guaranteed to be future proof. The problem is that when you trust someone else’s code to stand between your work and the finished product, if something doesn’t work quite right, you’re either at the mercy of the community to fix it quickly or you’ve got to sort out the fix yourself. Neither is an appealing proposition to me.

    Moreover, when Apple releases a new SDK with new/enhanced APIs, anyone comfortable with previous versions can get to work with the new APIs immediately, instead of waiting around for someone else.

    As for doing things that raise Apple’s ire, dunno what to tell you. PhoneGap apps were being rejected for awhile. There’s nothing unresearched about this — here’s a post on the subject. The FUD you complained about was created by Apple. I’m glad to hear that Apple has changed their view of PhoneGap. But I’m afraid Apple’s overall opacity means that any tool that stands between the developer and Apple’s officially-sanctioned methods of creating iPhone applications is a risk I can’t encourage anyone to take. Apple may bless PhoneGap today. They may change their mind tomorrow. I truly hope that we’re headed toward a more flexible and tolerant review process. Until that happens, though, it’s worth minimizing risk.

    Do I fear wasting a lot of development effort that gets rejected because Apple can be a control freak? Yup. Am I uncertain of Apple’s overall view of such things? Of course, we all are. Do I doubt that it’s a good idea to use anything but Apple-sanctioned tools? 100%, yes. Don’t take this personally, though. I’d say it about PhoneGap or anything else that wasn’t the real deal. And that doesn’t even get into the inherent compromises that come from writing an application that tries to be everything for every platform.

    While I get that PhoneGap is meant to be a cross platform solution, it bills itself thusly:

    “If you’re a web developer who wants to build mobile applications in HTML and JavaScript while still taking advantage of the core features in the iPhone, Android, Palm, Symbian and Blackberry SDKs, PhoneGap is for you.”

    I read that as “Hey, you web guys! Shortcut to mobile!” Because I don’t really concern myself with other mobile platforms at this stage, the fact that it can be a shortcut for other devices, too, is beside the point.

    Look, your company wants to make money selling services around PhoneGap. I get that. Way to be out there protecting its reputation. But making something that works on every platform is a surefire ticket to mediocre software that doesn’t look or work great on any platform. I think we can look to Java’s resounding success on the desktop as proof of that fact. What’s worse is that it’s risky for iPhone developers in particular, given Apple’s track record on “not invented here” intermediate code.

    Glad we’re in agreement, though, that using the official tools and APIs is the best way to build a great application.


  7. Danilo Campos January 23rd

    Comment Arrow

    Paul,

    Don’t love some of the other iPhone content I have from that publisher but the reviews for that book look great. I haven’t read it so I can’t endorse it either way. If you end up checking it out, let me know how it goes for you.

    Good point on the iTunes U iPhone content. I don’t love video lessons myself — books work better for me — but it’s a good for someone who prefers classroom style instruction to get started once they have the basics of C and Objective-C.


  8. Zap Rowzdower January 28th

    Comment Arrow

    Danilo. Hello Friend. I also would like to point out that you can learn Iphone SDK from the ground up at http://developer.apple.com/iphone/

    What are your personal opinions of the Ipad? Will you start developing software for that? I think it’ll be a big FLOP!

    Zapster R.


Add Yours

  • Author Avatar

    YOU


Comment Arrow