Pre-compilation Directives
1. It is best to use double quotation marks to write your own header files, and the system can use angle brackets.
*************************************************
Dot syntax
P.age= 10;
1. Instead of accessing the age member variable, call its method
2. Many other programming languages have a bit of syntax, so programmers can quickly master OC in order to add point syntax
3. When the compiler encounters the dot syntax, it will automatically convert it to: [P setage:10];
4. Therefore, the essence of point syntax is to invoke the method instead of accessing the member variable (the Access member variable is one: through the arrow).
*******************************************
ISA pointer
In OC, for each instance object, there is an Isa pointer, Isa= is a, which is the same as the ISA pointer of the object created by the same class.
Its purpose is to tell the object which class it is and who it is.
This pointer is visible only when the program is running (it can be found at specific objects in debug mode).
*******************************************
The difference between import and include:
The Import keyword automatically omits files that are repeatedly referenced, and include does not. Therefore, import avoids encountering "common but problematic duplicate reference header file errors".
In OC, we generally use import to refer to other header files.
**********************************
Key words
"@" symbol: The keyword is represented in OC.
@interface: The beginning of a class declaration.
@implementation: The beginning of the class implementation.
@end: The end of a class declaration or class implementation.
The declaration of a class sandwiched between @interface and @end, while sandwiched between @implementation and @end, is the implementation of the class.
**************************
In OC, self represents the object itself, and it has a similar meaning in C + +. Super represents the parent class object.
************************
Inheritance and overrides
Inheritance between class libraries:
In the framework of cocoa, most of the class libraries are inherited from NSObject, and there are a variety of parent-child relationships between class libraries, such as all control classes (Uicontrol, NSControl) are inherited from the responder class (Uiresponder, Nsresponder); All multi-function views (Tableview/scrollview/webview, etc.) are inherited from the view class (UIView, NSView) and so on. If we want to find the inheritance of the class library, we can find it in the development documentation.
************************
Category (category)
************************
Protocol (protocols) and agents (delegation)
1. The introduction of the agent in a real sense completely realizes the MVC program structure framework.
2. The agreement is a set of criteria for the implementation of the class, which guarantees the interface consistency of the classes that are committed to implementing the Protocol.
OBJECTIVE-C Basic Knowledge