Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Objective-C++ for iOS development

Is it possible to use Objective-C++ for iOS application (iPhone, iPad, iPod touch) development?

Are there any examples and source code on the Internet?

like image 695
nik Avatar asked Feb 23 '11 12:02

nik


People also ask

Can you still program iOS with Objective-C?

Most of the core iOS and MacOs software is still written in Objective-C, though Apple is pushing for new updates to be written in Swift.

What is Objective-C in iOS development?

Objective-C is the primary programming language you use when writing software for OS X and iOS. It's a superset of the C programming language and provides object-oriented capabilities and a dynamic runtime.

Is Objective-C still supported by Apple?

Community & supportAlthough Objective-C is still supported by Apple, it has never been an open-source language.

Is Objective-C only for iOS?

Objective-C overviewThe Objective-C programming language is an object-oriented language used to develop various apps and software, including iOS and OS X. It's a superset of the C programming language, meaning it can do everything C can.


1 Answers

Using ObjC++ is quite easy. You have to declare source files with extension .mm. It will make compiler treat them as ObjC++. The same with headers: use the .hh extension.

There is another option: go to target settings and set Compile Sources As to Objective-C++.

That's all. No additional work is necessary.

Some notes: if you want to develop a native iOS app, then use Objective C. It will save a lot of time. But in some cases using C++ is more appropriate. E.g. for cross-platform development. So you use only a little bit of Objective C for iPhone or Java for Android just to glue your code with environment. Everything else in C++. I use this for my cross-platform game development.

Another case is performance: Objective C is principally slower then C++. However it is only noticeable during method calls (in ObjC it is called messaging).

like image 72
Max Avatar answered Sep 24 '22 13:09

Max