开发者

Objective-C++ for iOS development

开发者 https://www.devze.com 2023-02-12 16:58 出处:网络
Is it possible to use Objective-C++ for iOS application (开发者_C百科iPhone, iPad, iPod touch) development?

Is it possible to use Objective-C++ for iOS application (开发者_C百科iPhone, iPad, iPod touch) development?

Are there any examples and source code on the Internet?


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消