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?
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.
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.
Community & supportAlthough Objective-C is still supported by Apple, it has never been an open-source language.
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.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With