Utilizing C++ in iOS and Mac OS X applications

I'm somewhat moderate in my C++ knowledge but know next to nothing regarding Objective-C. I am planning (and even starting to) learn Objective-C so I can attempt to write a few iOS and even Mac OS X applications but I'm very curious about something I haven't been able to find yet.

Is it possible to write an iOS and / or a Mac OS X application entirely with C++ including the UI components? If it isn't possible to do it entirely in C++ then to what degree is it possible to use mostly C++?

I haven't seen any examples that demonstrate either of these items. I am planning on writing a few mobile applications for iOS and Android and, where possible, I'd like to contain most of my logic inside of C++ code for maximum portability. I already know I can do this but I am unsure of the degree.


Solution 1:

Short answer, yes.

For pure C++, you should take a look at the QT framework.
Otherwise, you'll have hard time for the UI part.

But also remember that Objective-C can be mixed with C++.
That's called Objective-C++ (.mm files).

You can then write code that mix C++ and Objective-C code. With this, you can have the UI parts in Objective-C (may be better, as it will use the native frameworks for the UI components), and the other things in C++.

If you've decided to learn Objective-C, but still want to code in C++ for some parts, I would recommend this approach, instead of pure C++.

On iOS, this is also the only way. While you can code in C++, you have to use Objective-C for the UI part.

EDIT

Here are a few links to get started with Objective-C++:

  • Strategies for Using C++ in Objective-C Projects
  • From C++ to Objective-C
  • CocoaDev

Solution 2:

Look this question

I don't know about Mac OS, but in IOS applications you can use C++ in logic but you have to write user interface on Objective-C.

Solution 3:

Is it possible to write an iOS and / or a Mac OS X application entirely with C++ including the UI components? If it isn't possible to do it entirely in C++ then to what degree is it possible to use mostly C++?

I think it is possible to use pure c++ if you want to depend on some 3rd part lib, then yes.

Without that 3rd part lib you have to write all the UI using objective-c the rest you can use c++ as much as you like.