How to leave the world of OBJ-C as early as possible and enter an existing C++ codebase in an iOS OpenGL ES app?
I'm looking to write an iPhone app which utilises an existing OpenGL (which will be ported to ES) code base. I can't spend too much time invested in learning OBJ-C, so if I can limit its usage to the bare essentials (Input/OS stuff etc...) that would be great.
I know how to wrap the C++ code in opaque pointers to get the languages to play together but I need to know how to compile the C++ code (preferably within a windows environment) to be linked within X-Code. (not sure if thats the right question?)
Once it's linking I would like to know the best (earliest) way I can leave OBJ-C and get to my 'nice and happy' world of C++?
I can refine the que开发者_开发问答stion if this doesn't make sense...
You can write C++ code or Obj-C++ (a mixture of the two languages) code at any time during your project's development. In order to get Xcode to compile the C++ correctly, you need to set the build settings in the info for your target(s) (or project). If you right click on a target and go to "info", or double click on the project in the left-hand-side pannel in Xcode and look on the "build" tab, you'll see an option "Compile Source As", which you need to set to Objective-C++. You also need to ensure that any source files with C++ code within them (or include other C++ files) are named with the extension '.mm'. This tells the compiler that there's C++ or Objective-C++ in the source file.
As far as getting to happy C++, other than the initial Objective-C code that's required to start your app and handle the AppDelegate, you could write your entire app in C++. You would miss out on all the code Apple provides in their frameworks though, which could be excedingly beneficial!
精彩评论