views:

468

answers:

6

I'm a PHP developer, and I use the MVC pattern, and object oriented code. I really want to write applications for the iPhone, but to do that I need to know Cocoa, but to do that I need to know Objective-C 2.0, but to do that I need to know C, and to do that I need to know about compiled languages (versus interpreted).

Where should I begin? Do I really need to begin with plan old "C", as Joel would recommend?

Caveat: I like to produce working widgets, not elegant theories.

A: 

I think starting with C would be a smart thing to do. After all, Objective-C is C language with some extensions.

To develop in Cocoa you are required to know well how pointers and memory allocation work (there's no garbage collection on the iPhone), plus you will have to use some standard C libraries, because a lot of the frameworks that are used to develop for the iPhone are C libraries not Cocoa libraries. Take for example CoreGraphics, the library you have to use to draw on the screen on the iPhone. That's a C framework, meaning that it is not written in Objective-C.

Of course after learning C to a modest level, you could start reading about Objective-C and Cocoa, and in that case I would start with the Objective-C language specification (link to PDF) and the Aaron Hillegas book on Cocoa.

Sergio Acosta
+2  A: 

Get Cocoa Programming For Mac OS X by Aaron Hillegass. This should get you on your way to Cocoa programming. You can look up C-related programming as things come up.

K&R C Programming Language is the definitive reference that is still applicable today to C programming.

Get the Cocoa book, work though it and if you encounter any snags, just ask your C questions here :)

Misha M
A: 

No need to start with plain C. Start with an excellent book instead: Cocoa Programming for Mac OS X.

Frank Krueger
+2  A: 
dlamblin
+5  A: 

Yes, you're really best off learning C and then Objective-C. There are some resources that will get you over the C and Objective-C language learning curve:

And there are some resources that will get you over the framework learning curve:

Despite what Jeff might say, learning C is important for professional software developers for just this reason. It's sort of a baseline low-level lingua franca that other innovation happens atop. The reason Jeff has been able to get away with not learning C is not because you don't need to know C, but because he learned Pascal which is in many ways isomorphic to C. (It has all the same concepts, including pointers and manual memory management.)

Chris Hanson
A: 

The memory management concepts that are (or were, depending on if you like the whole garbage collection thing) central to the Cocoa frameworks can be a little confusing. This is particularly true for those coming over from languages such as PHP, Python, Ruby, or even Java. Knowing C, or C++ for that matter, put you at a great advantage when learning Objective-C and Cocoa.

eczarny