<a href= "http://www.goodprogrammer.org/" target= "blank" >ios training </A>------My obj-c language notes, looking forward to communicating with you!
#import <foundation/foundation.h>int Main (int argc,const char** argv) { NSLog (@ "Hello obj-c"); return 0; }
1. header file:
#import can guarantee that the header file is included only once, regardless of how many times the command actually appears in that file (equivalent to the #ifdef #define in C #endif)
#import <Foundation/Foundation.h> tell the compiler to view the Foundation.h header file in the Foundation framework
2. Obj-c Style string @:
@ "String" is one of the attributes added by obj-c on standard C, which means that the referenced string should be treated as a nsstring element of the cocoa. (nsstring element "NS" +string).
3, "NS" prefix:
"NS" originates from "NextSTEP" (later renamed to Cocoa); It shows that this function is from cocoa;
Adding a prefix can make the code clearer, readable, and prevent name collisions;
4. NSlog () function:
The printf () output function, similar to C, accepts a string as its first argument, which can contain the format specifier (%s);
"Good Programmer's note sharing" the similarities and differences between OBJ-C and C + + from Hello World