I. INTRODUCTION of OC
On the basis of C language, a layer of minimal object-oriented syntax is added, fully compatible with C language, C language code can be mixed in OC code, or even C + + code, and you can use OC to develop applications for Mac OS x platform and iOS platform.
Second, OC Syntax Preview (i) keywords
Basically all the keywords are at the beginning of the @, such as @interface @implementation @public, and so on, a small part does not start with @, such as Id,_cmd
(b) The string begins with @
C-language string: "Hello"
OC language string: @ "Hello"
(iii) Other grammatical
Basic type: 5, added Boolean type bool (yes/no).
Nil equals null in C, which is 0.
Screen output: NSLog (@ "Hello"); NSLog (@ "Age is%d", 2); Wrap Line
Third, OC program development process
#import预处理指令有两个作用: (1) As with # include, the Copy file contents (2) can automatically prevent the contents of the file from being copied repeatedly
The program compiles the connection process:
source file (. m)---(compile)----> destination file (. 0)-----(link)----> executable (. Out)
Foundation Framework. is the development of OC, IOS, MAC program necessary framework, if you want to use the entire framework of content, including the framework of the main header file. The primary header file is the most important header file in a framework, with the main header filename and frame name consistent for each frame.
namely: #import <Foundation/Foundation.h>
Run the following procedure:
(1) Write the OC source file. M. C
(2) Compiling files cc-c xx.m xxx.c
(3) Link cc XX.O xxx.o-framework Foundation (without using the foundation framework, you do not have to add-framework Foundation)
(4) run./a.out
Iv. type of bool
int main ()
{
BOOL B=yes;
BOOL B1=no;
BOOL b2=1;//YES
BOOL b3=2;//NO
NSLog (@ "%i", b);
}
Essence:
typedef signed Char BOOL;
Typedef signed Char BOOL
Macro definition:
#define YES (BOOL) 1
#define NO (BOOL) 0
The output of a Boolean type is generally used as an integer.
Reprint Address: http://www.cnblogs.com/xiaodong208/p/4232589.html
"oc" Basic Syntax