I am very good at C/C++ but can't get the Obj C syntax. Is there an app where I can type the complete source code of my app in C/C++ and when I click "Convert", it automatically converts the source code to Obj. C. ?
This would be very helpful... :)
Printable View
I am very good at C/C++ but can't get the Obj C syntax. Is there an app where I can type the complete source code of my app in C/C++ and when I click "Convert", it automatically converts the source code to Obj. C. ?
This would be very helpful... :)
You can mix C or C++ code with Objective C
Do you mean that the syntax for Obj C is a mixture of syntax of C and C++ ?
Well, then what about taking inputs from user and displaying outputs..
In C, we use: scanf and printf
And In C++, we use cin>> and cout<<
Now how is the syntax of Obj C. related to this...
If you look at the source code of nes.app from NerveGas here (http://www.zdziarski.com/projects/nesapp/). You can see there are C code source files.
However, iPhone has no command line interface in the UIKit, so you have to mix C code with Objective C code (for UIKit API).
As you probably aware that every iPhone app has a
int main(int argc, char *argv[])
and that is C syntax.
Objective C is a hybrid of C syntax and Smalltalk. And later it adds C++ syntax to it so now you can mix C / C++ code with Objective C.
If you build command line utility, you can use printf. But it is only for jailbroken iPhone.
P.S.
If you mix C++ code and Objective C, the source file name should end with .mm
If you use C++ syntax only in the source code, the filename should end with .cpp
You must use objective C for the UIKit API because there is no bridge for UIKit API (official SDK) to other languages.
But you can use C++ classes and mix them with Objective C. It is called Objective C++ in Objective C language.