Features of OC
● On the basis of the C language, a minimal object-oriented syntax is added.
fully compatible with C language
You can mix C code, even C + + code, in OC code
applications that can use OC to develop Mac OS x platform and iOS platform
object-oriented versus process-oriented differences:
①oc is Object-oriented
②C is process-oriented
③ object-oriented and facing over-becoming is just two different ways to solve the problem
④-oriented process is only a matter of solving the problem, object-oriented is only to consider the object to solve the problem.
Key Words:
Example: @interface, @implementation, @end
Note: Basically all the keywords start with @
code Exercise (First OC program):
#import <foundation/foundation.h>int Main () { ///NSLOG output is automatically wrapped NSLog (@ "First OC program"); return 0;}
1. #import
①, like include, is used to copy the contents of a file
② can automatically prevent file contents from being copied multiple times
the role of the 2.Foundation framework
① the necessary framework for developing OC,IOS,MAC programs
② This framework contains a number of commonly used API (application programming interfaces)
③ Framework contains a lot of header files, if you want to use the entire framework of content, including its header file can--#import <Foundation/Foundation.h>
use of bool:
The nature of the bool type
Tupdef signed Char BOOL;
There are two values for variables of type bool: YES NO
#define YES (BOOL) 1
#define NO (BOOL) 0
Output of bool (As Integer)
NSLog (@ "%d%d", yes,no);
nslog differs from printf:
1.nslog receives the OC string as a parameter. printf receives the C language as a parameter in the string
2.nslog output is wrapped and will not wrap automatically after printf output
3. NSLog #import required to use <foundation/foundation.h>
4. Using printf requires #include<stdio.h>
"Dark Horse Programmer" recognizes OC's first program (OBJECTIVE-C)