Objective-C – Required C/C++ Knowledge for iPhone Development

ciosiphone

First, a little background. I'm a .Net developer (C#) and have over 5 years experience in both web development and desktop applications. I've been wanting to look into iPhone development for some time now, but for one reason or another always got side tracked. I finally have a potential project on the horizon, and I'm now going full steam ahead learning this stuff.

My question is this: I haven't done any C/C++ programming since my schooling days, I've been living in managed land ever since. How much knowledge if any is needed to be successful as an iOS developer? Obviously memory management is something that I'll have to be conscious about (although with iOS 5 there seems to be something called ARC which should make my life easier), but what else? I'm not just talking about the C API (for example, in order to get the sin of a number, I call the sin() function), that's what Google is for. I'm talking about fundamental C/C++ idioms that the average C# developer is unaware of.

Best Answer

Don't worry about it. If you know enough C to be able to write function calls, understand and write arithmetic expressions, and deal with pointers, you'll probably be fine. You'll still need to learn Objective-C, of course, but much of the code that you'll write will be more Objective-C than plain old C. Getting used to Objective-C style and learning Cocoa Touch will consume much more of your time than brushing up on C.

I usually tell people who are starting from zero to learn C before jumping into Objective-C. I stand by that advice -- learning C will teach you basic knowledge that you need in order to work effectively in Objective-C. You need to know what a function is, how to use control structures like loops and conditional statements, how the various basic data types work, what a struct is and so on. And since all of C is fair game in Objective-C, the more C you know the better you'll be prepared to understand code you might run across. That said, many tasks are done differently in Objective-C, so standard C idioms aren't necessarily standard Objective-C idioms. NSString and NSArray take the place of C-style arrays. Pointers are ubiquitous, but they're used mainly to refer to objects -- pointer arithmetic doesn't come up very often. Instead of allocating memory directly, you create objects.

The same goes for C++... you won't need much C++ to get along fine in Objective-C. At some point in the future you might need to increase your C++ knowledge in order to integrate some existing C++ code into an app, and at that point you might need to spend some time learning, but don't let a lack of C++ knowledge stop you from trying your hand at iOS programming.

Related Topic