Access objective-c from c++
Can somebody point me in the right direction for this. I've found lots of info on using c++ in obj c but not the other way around. I am making an iPhone game in c++ but need to t开发者_如何学Cap into some of the features the iPhone has to offer.
Thanks
There's actually no difference between "using C++ in Objective-C" and "using Objective-C in C++" - they're both actually using Objective-C++ (which is a distinct language).
Just make sure that you're compiling the source file as Objective-C++: either rename it with a .mm
extension, or add the compiler flag -x objective-c++
to affect all of your source files.
Then you can do just about anything that you would do in Objective-C.
Normally the way is to do the opposite, you rename your files to .mm and then use C++ in the files. It sounds as if you are trying something will cause you extra work without necessarily any benefits.
精彩评论