Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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.

share|improve this question
1  
Why does this have anything to do with C++ ? –  sdg Nov 24 '11 at 1:54
    
From what I've read, there are many API's that iOS developers interact with that are written in C++. Is that not true? –  BFree Nov 24 '11 at 1:56
    
C or Objective-C. No C++ required. –  Terry Wilcox Nov 24 '11 at 2:32
    
@BFree you rarely need to use C++ for iOS development. Unless you are doing something that requires specific libraries like OpenCV or Irrlicht, you'll be mostly doing Objective-C. Cocoa Touch is written in Objective-C and it's Apple's set of frameworks you'll mostly use. –  rightføld Nov 24 '11 at 21:41

3 Answers 3

up vote 7 down vote accepted

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.

share|improve this answer

Not a full answer, but you need to check out this pdf if you're going to learn Objective-C.

It's a really easy read if you like to read to learn languages, as opposed to looking at sample code or examples. As long as you have an understanding of OOP then picking up Obj-C is smooth sailing. The thing that really puts me off about learning iPhone dev is the use of Xcode, which is another story....

Apple Obj-C

share|improve this answer

Depends.

A programming language subset (sometimes called "the good parts") usually works fine if your goals don't push the limits of that subset.

If you want to do simple UI stuff (the stuff you could do in a web app), stick with Cocoa and Foundation data types, and you write bug-free code, you could probably get by knowing very little of the C underneath Objective C.

However, if you want to do iOS audio, video, image (etc.) processing or analysis, the APIs and reference example code you will likely be working with are mostly in C, and are C idiomatic.

But Objective C is a strict superset of C, so the typos and bugs can manifest themselves at any level of the language environment. If your code has bugs, then you may need to know stuff in depth at the C pointer, data type, and heap level to analyze a crash and debug it. Objective C is not "managed" and thus one can create a gnarled mess in memory either or purpose or as a complete accident.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.