1. It is used to notify an object of what to do, that is, the notification object executes an action.
1.1. in objective-C, square brackets also have other meanings: they are used to notify an object of what to do.
For example:
[Shape draw];// This statement indicates that the shape of the notification object is used to execute the draw action. For example, a rectangle is used to draw a rectangle.
1.2. In objective-C, the notification object performs an operation, which is called sending a message.
For example:
[Shape draw];// Send a draw message to the object shape.
2. Create a new object
To create a new object, we need to send a new message to the corresponding class.
After receiving and processing the new message, this class will get a new object instance that can be used.
For example:
Id shape [3];
Shape [0] = [circle new];// Send a new message to the Circle class. A new object is created and assigned to shape [0].
3. Send messages to the superclass in the class
3.1 for example:
@ Interface circle: Shape
@ End // circle
@ Implementation circle
-(Void) setfillcolor :( shapecolor) c {
If (C = kredcolor ){
C= Kgreencolor;
}
[Super setfillcolor: C];
// Send a message to the superclass shape. The superclass will execute its setfillcolor method.
}
@ End // circle
3.2 for example:
Self = [Super init];// Enables the superclass nsobject to complete its initialization. And if a new object is returned,
// Update self.