Objective-C++ for iOS development

前端 未结 2 1445
遥遥无期
遥遥无期 2021-01-05 08:31

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?

相关标签:
2条回答
  • 2021-01-05 08:47

    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).

    0 讨论(0)
  • 2021-01-05 09:00

    Yes, you can. Take a look at the samples and new file templates that Apple provides.

    0 讨论(0)
提交回复
热议问题