In the previous section, the hello WorldProgram, Here we will further elaborate on this program,Source codeAs follows:
# Import <Foundation/Foundation. h> int main (INT arvc, char * argv []) {nslog (@ "Hello world! "); Return 0 ;}
1. Objective-C contains the keyword import of the header file, which is mainly because of GCC support and also supports include. The main difference between import and include is that after using import, # ifdef/# define/# endif is not required in the header file to prevent repeated inclusion of header files, which is similar to C # and Java
2. function. h contains all header files.
3. Currently, nslog can be considered as a printf encapsulation, although not so simple
4. The nslog prefix ns is short for nextstep. To prevent conflicts with other function names
5. Cocal is a library with ns as the prefix. Cocal is similar to boost
6. @ indicates that the string needs to be processed as the Cocal nsstring, because the nslog received parameter is nsstring.
Change the source code:
# Include <stdio. h> int main (INT arvc, char * argv []) {printf ("Hello world! "); Return 0 ;}
It can also be compiled. The difference is that nslog outputs a lot of content, such as time information.
Learn objective-C (1) -- install the development environment and hello World in Windows
Learn objective-C (2) together -- Hello World
Learn objective-C (3) together -- How to declare and define classes