I want to make an iPhone app, but I am planning to make the framework in C++. Is it possible to use things like templates in Objective-C++. I guess really the question is, can I use boost?
Objective-C is an object-oriented programming language that is a superset of C, as the name of the language might reveal. This means that any valid C program will compile with an Objective-C compiler. It derives all its non-object oriented syntax from C and its object oriented syntax from SmallTalk.
While Objective-C is still supported by Apple and will likely not be deprecated anytime soon, there will be no updates to the language. Objective-C is as good as it's ever going to get.
There are a lot of indicators telling us there's still a ton of legacy Objective-C code, both from Apple and from other developers, that's still in use.
Objective C can be called the super set of C language. It contains classes and objects in addition to C language. The pointers used in C language are vulnerable to security attacks. The language objective C uses null pointers and hence is type safe compared to C.
Is it possible to use things like templates in Objective-C++.
Yes, but you need to take care how you mix types and interfaces between the pure C++ layers and the Objective-C++ code. Keep in mind the boundaries between layers, where you would need to convert types such as std::string
to NSString
, and so on.
For example, you could implement the core game engine in pure C++, and just implement your controllers and GUI code in Objective-C++. Then the Obj-C++ code is the glue between the pure C++ engine and Cocoa.
I guess really the question is, can I use boost?
Given the iPhone OS is a subset of OS X that still provides a full POSIX layer, most Boost libraries should work just fine. It should be just like writing Darwin code.
There are a number of limitations in Objective-C++ to be aware of (taken directly from the Objective-C 2.0 Reference Guide):
All of C++ is supported in Objective C++. It should be possible to use boost, but you might have to port some of the platform dependant things.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With