[Learning notes] [OC language] The first OC program, learning notes oc
1. # purpose of import:
1> like # include, copy the file content
2> automatically prevents duplicate copies of File Content
2. # import <Foundation/NSObjCRuntime. h>
NSObjCRuntime. h contains the NSLog function declaration.
3. Path of the header file of the Foundation framework
1> right-click Xcode. app --> display Package content
2> Xcode. app/Contents/Developer/Platforms/iPhoneOS. platform/Developer/SDKs/iPhoneOS6.0.sdk/System/Library/Frameworks/Foundation. framework
4. Master header file
1> main header file: The main header file, which is generally the same as the framework name and contains all other header files in the framework.
2> the header file name of the Foundation framework is Foundation. h.
3> you only need to include the main header file of the Foundation framework to use the entire framework.
5. Running Process
1> write OC source files:. m,. c
2> compile: cc-c xxx. m xxx. c
3> link: cc xxx. o xxx. o-framework Foundation
(The-framework Foundation must be added only when the Foundation framework is used)
4> Run:./a. out
1 // # include <stdio. h> 2 # import <Foundation/Foundation. h> 3 4 // all use the main function as the entry 5 int main () 6 {7 // printf ("1st OC Programs \ n "); 8 9 // NSLog output content will automatically wrap 10 NSLog (@ "1st OC programs !!! "); 11 12 return 0; 13}
Running result