Sign up ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

Please forgive the humor of the title but it certainly gets my point across. I am quite familiar with C code, I can write it in my sleep and after reading through a few tutorials on iPhone development and Objective-C, I'm beginning to feel like I'd rather avoid Obj-C at all costs.

It's not that it's unlearnable or "hard". I just don't like it and after reading through many of the Pros and Cons of Objective-C vs. straight C, I've determined that if I need to write an iPhone App, I want to write as much of it as C as is possible.

With that said, what is the minimum amount of Objective-C that I need to be aware of or potentially write to be able to create an iPhone app?

If I can't write an app 100% in C, then is there a good reference that discusses writing iPhone Apps in C and only discusses the minimal amount of Objective-C logic that needs to be written to get an application to compile and run?

Also, is there any good reason why I should learn Objective-C if I don't have to use it for a C project? Specifically, are there times when Objective-C may provide a more optimal coding solution to a problem because of the way the compiler compiles and link the code? I may be a C advocate but more important than that I want to be sure that my application runs as smooth and optimally as possible.


I am at an early learning stage of a project I may have to work on in the near future. If this process comes to fruition, I'll be getting a Mac as well as a developer license so I'm completely in ignorance. Even worse, if this project is determined to be feasible, I will then be getting the necessary equipment to develop for the iPhone. For now, I'm trying to learn as much information as I can and explore my options.

I'd appreciate any (constructive) thoughts, tips and suggestions.


migration rejected from Jul 31 '14 at 15:17

This question came from our site for professional and enthusiast programmers. Votes, comments, and answers are locked due to the question being closed here, but it may be eligible for editing and reopening on the site where it originated.

closed as off-topic by GlenH7, Wayne M, MichaelT, Bart van Ingen Schenau, Ampt Jul 31 '14 at 15:17

  • This question does not appear to be about software development within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

This question appears to be off-topic because it is not about a conceptual programming problem. In addition, answers to this question are likely to be ephemeral as the subject operating system (iOS) will change with each new release. – GlenH7 Jul 25 '14 at 11:23
Then lock it, rather than down vote it. I asked this question nearly 3 years ago, on SO. It was migrated here and was received well enough at the time. Thank you for keeping the site clean (seriously) but it's not like I can go back in time and re-map this question to what this site is expected to be, today. – RLH Jul 25 '14 at 11:58
I didn't expect you to edit or update the question. And you're correct - the site's scope has changed. Part of keeping the site clean involves closing out old questions that don't meet the site's scope. My comment was part of the custom close reason that I provided for my vote to close. – GlenH7 Jul 25 '14 at 13:58
No problem GlenH7. I just assumed (possibly inappropriately) that you were the same person who down-voted the question the same day that you requested to close it. This has happened to me a few times in the past on StackExchange-- I ask a question and 2-3 years later it gets down-voted due to the fact that it's no longer within the scope of the site. My response is always the same-- I politely, but curtly, request that my questions be flagged rather than down-voted. If you aren't the one who gave the down-vote, then I appologize for assuming that you were. – RLH Jul 25 '14 at 17:29

5 Answers 5

up vote 6 down vote accepted

All of the view related classes supplied by the system are Objective-C, and they're generally written to expect to communicate with other Objective-C objects (though that's not as true as it was since blocks were added in iOS 4). However, Objective-C is a strict superset of C and all C code is directly callable. C code can be directly included in Objective-C source files, with the effect that C source can make Objective-C calls as necessary. So to remain neat I'd say that to build an application with the minimum amount of Objective-C, you should stick with model-view-controller, implement the view and controller in Objective-C and the the model in C.

The primary differences between Objective-C and C are the usual object oriented versus procedural differences plus the fact that the former is fully reflective, which in practice tends to bring efficiency savings in coding because of the permissible implementation patterns it opens up, such as target/action or key-value observing. The way Apple's frameworks are built up, to rest on ideas like delegation, also provide implementation efficiency gains over common C practices.

As hinted by Noah, all Objective-C tasks are achieved by C function calls, as documented in the Objective-C Runtime Reference. If you really wanted to get messy you could create Objective-C classes at runtime, supply the C functions you want to be linked to each method and then talk to Cocoa like that. It'd be unlikely to be syntactically pleasing, but the option is there.


With that said, what is the minimum amount of Objective-C that I need to be aware of or potentially write to be able to create an iPhone app?

Technically, none. You can replace any [foo someMethod:bar] with a call to the C function objc_msgSend and its variants, as in objc_msgSend(foo, @selector(someMethod:), bar) (more info on that here). It’ll make your code enormously more verbose, though, and as many of the frameworks on the OS—including almost the entirety of UIKit, the framework responsible for most user interaction and all of the standard UI—are written with Obj-C in mind, you’ll find yourself doing a lot of extra typing if you want to avoid using the standard syntax.


is there any good reason why I should learn Objective-C if I don't have to use it for a C project? Specifically, are there times when Objective-C may provide a more optimal coding solution to a problem because of the way the compiler compiles and link the code?

The angle that Objective C has above C: just think in terms of messaging which is built into the language. Implementing multithreaded POSIX (pthread) applications in C uses lots of message passing (or sockets; rarely signals). With ObjC this is just "built in" as a language construct and instead of making direct function calls to the same-context library or direct function calls to message senders which put a message into a queue, in ObjC a message is sent to the "library" with one line of code. As part of the language, this also ensures the communication method is standardized, clean, and difficult to do improperly. Really that's the major difference. The minor difference is in creating automatic variables for the data-structures-cum-objects defined by your app (or your library), and handling strings as objects using @ (which is a great language improvement, one which C has always needed for implementing layer4 and above).

The bigger issue of course is learning the thousands of new "function calls".


Look into some of the OpenGL game examples, where almost an entire huge app (Wolfenstein, Doom, can be coded in C, except for an initial view set-up and some UI event handling delegate stubs (maybe around a couple pages worth).

Even the latter can be done in straight C if you don't mind being much more verbose, by calling the UI APIs via the messaging runtime interface (see Noah's answer).

All of the example code and support is for using the UI APIs via Objective C, so you may end up having to write a ton more of your own custom UI code (as games sometimes do).


To write native Cocoa Touch apps, I'm not aware of any workaround Objective-C.
If you are going to develop iOS games however, you can enjoy C/C++ coding but you still need to write some Objective-C code to launch the app among other things.


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