Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Vegeta-san

macrumors 6502
Original poster
Aug 4, 2006
432
0
Hey all. So I'd like to start coding iPhone apps. A couple weeks back, I checked out the MacRumors Cocoa FAQ (http://guides.macrumors.com/Cocoa_FAQ) and, following its suggestion, borrowed the "The C Programming Language" by Kernighan and Ritchie (2nd ed.) book from my library. I opened it up, started reading, opened XCode, and was immediately confused as to how to do what it suggested within XCode. So I google'd and came across this Macrumors thread: https://forums.macrumors.com/threads/592502/. Now I am honestly confused as hell as to whether I should continue with this book or get another book or what. I just need a definitive answer as to what I should use to begin heading down this road. Can't believe it's this difficult.

A little background: I am now 26. Two years out of high school, I took a beginning C++ class called "Algorithms and Computing with C++" as it was part of my Engineering curriculum. As much as I 4.0'd it, I honestly never thought I'd need the information again and never made a point of staying up with the content and applying my programming knowledge (so I vaguely recollect C++ stuff). Now I'm about to enter med school (fall of 2010) and I see much potential in iPhone medical related apps and would like to get into developing them. I want to make it a point that I really don't want to ever make Windows applications, so please excuse any recommendation of learning a language that will allow me to code on a broad basis. I would really only like to learn how to create Mac OS X applications, iPhone applications, and maybe Android apps (potentially in the future).

So ultimately, I just need guidance as to what book I can start to read that will supply me with the basis needed to create applications for those platforms. Is there really no consensus as to how a beginner should proceed?
 
Now I am honestly confused as hell as to whether I should continue with this book or get another book or what. I just need a definitive answer as to what I should use to begin heading dow

OK, there's a number of skills needed to make iPhone apps:

  • You need to know how to program in general
  • You need to know some C (just enough to work out what's going on with pointers)
  • You need to know Objective-C
  • You need to learn how to use the Cocoa frameworks. This one splits into two things: firstly how the frameworks fit together and the common patterns they use, and secondly how to use the documentation to find the bits you need

Note I don't say you actually need to learn all of Cocoa. That'd take ages. You need to know how to find the bit you need using the documentation. Much more sensible :)

So, you can either learn that lot all at once, or you can do it one step at a time. When I learnt Cocoa (before the iPhone), I already knew how to program but didn't really know C. I jumped right in and learnt all the rest of the things together, using some books on Cocoa from my university library. The learning curve was tough (it takes a while before you get anywhere at all), but in a summer I had a basic app up and running, that included graphics and networking.

The important thing is knowing how to program. By that I mean how to break down a concept into small tasks, knowing stuff about how a computer sequentially executes instructions, knowing what a variable is, that kind of thing. With a C++ class under your belt you should be OK at this, or at least not scared by the concepts. My advice is if you think you know something about programming, it's OK to try and learn C, Objective-C and Cocoa at once (although the learning curve will be steeper). To anyone who doesn't already know how to program, either learn C first or learn some other language first, while learning about programming. It'll save headaches!

Regarding how to use the K&R book with Xcode, in Xcode go to New Project, and choose Command Line Tool, and select "C" from the "type" popup menu. In the sidebar, in the Source folder, it will have made you a "main.c" file. Put your code in that, and use the toolbar button "Build and Run" to compile and run it. To see the output of your program (and interact with it if you've made it interactive), press Command-Shift-R to bring up the Debugger Console in Xcode.

To sum up: if you're the type who likes to completely understand each step before moving on, you'll be best served learning C, then Objective-C, then Cocoa. If you're the type who wants to aim straight for the goal, and crucially you have at least some programming experience, then by all means try to learn them all at once. Be aware that doing so might seem a slow process!

Amorya
 
Amorya gave an excellent answer. One of the better replies to similar questions in this forum.

The only thing I'd add is that one learns to program and develop by programming and developing. If you are stuck getting started, grab one of the video tutorials from the Apple developer web site and copy the steps. Then integrate that with what you've read and start building on what you've done. Rinse and repeat.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.