What is Objective C++? [closed]

2019-01-03 23:05发布

What is Objective C++ and can I use this language in Xcode?

3条回答
Ridiculous、
2楼-- · 2019-01-03 23:48

Objective-C++ is simply source code that mixes Objective-C classes and C++ classes (two entirely unrelated entities). Your C++ code will work, just as before, and the resulting executable will be linked with the Objective-C runtime, so your Objective-C classes will work as well. You can definitely use it in Xcode -- name your files with the .mm extension.

Also, you might want to read Apple's (sadly deleted, but archived) documentation on Objective-C++.

查看更多
迷人小祖宗
3楼-- · 2019-01-03 23:58

If you want to use Objective-c++ but don't want to name your files .mm checkout my answer to a similar question.

Without changing any .m to .mm or anything like that, if you click your project, click tagets->build settings go all the way down to "LLVM GCC 4.2 - Languages" (new xcode says "Apple LLVM compiler 4.2") you will see Compile Sources As change that value to Objective-C++;

查看更多
\"骚年 ilove
4楼-- · 2019-01-04 00:09

Objective-C++ is Objective-C (probably with Cocoa Framework) with the ability to link with C++ code (probable classes).

Yes, you can use this language in Xcode to develop for Mac OS X, iPhone/iPodTouch, iPad. It works very well.

You don't have to do anything weird in your project to use Objective-C++. Just name your Objective-C files with the extension .mm (instead of .m) and you are good to go.

It is my favorite architecture: develop base class library of my game/application in C++ so I can reuse it in other platforms (Windows, Linux) and use Cocoa just for the iPhone/iPad UI specific stuff.

查看更多
登录 后发表回答