A grammatical basis
1 Key Words
Keywords are basically at the beginning of the @, the common keywords are as follows:
@interface, @implement, @end, @public, @private, @selector, @required, @encode, etc.
Other Id,self,super, etc.
2 string begins with @
@ "Hello world!"
3 Boolean type yes/no
4 Null type nil (value 0)
5 other C-language syntax
HelloWorld Program for two OC
Helloworld.m#import <Foundation/NSObjCRuntime.h> #include <stdio.h> int main () { printf ("OC fully compatible c\n "); NSLog (@ "Hello world");//auto-wrap return 0;}
The CC in MAC is used for clang compilation.
Compile:
Cc-c HELLOWORLD.M
A HELLOWOLD.O is generated below the current folder
Link:
CC Hellowork.o-framework Foundataion
A a.out is generated below the current folder
Run:
./a.out
Will print on the screen:
OC fully compatible with C
2015-01-28 19:10:49.451 a.out[503:507] HelloWorld
More than three files
Main.m#import "Helloworld.h" int main () { show (); return 0;}
#import <Foundation/NSObjCRuntime.h> #include <stdio.h>//helloworld.hvoid Show () { printf ("OC fully compatible c\ n "); NSLog (@ "HelloWorld");}
Compile build. o File:
Cc-c main.m
Link Birth to A.out
CC MAIN.O
Operation mode and result ibid.
iOS Review notes 2:objective-c syntax basics