1, used to inform an object what to do, that is, to notify the object to perform an action. In Objective-c, the meaning of "[]": They are used to inform an object what to do. The behavior of this notification object to perform an operation is called a "send message." For example: [shape draw]//This sentence means that the object shape is notified to perform draw, which means that the draw message is sent like the object shape. 2, create new Object 2.1 In order to create a new object, we need to send the corresponding new message to the class. Once the class has accepted and processed the new message, we will get an instance of the object that can be used. Example: ID shape[3]; Shape[0] = [Circle new]; When you send a new message to the Circle class, you create an object and assign the new object to Shape[0]. 2.2 uses a method in the class to return an instance of the class corresponding to the return value type of the method. NSData *now = [NSDate date];//indicates that a date message is sent to the NSDate class, the date method of the NSDate class creates a NSDate instance, initializes it to the current time, and then returns the starting address of the new object. 3, send a message to the superclass in class 3.1 For example @interface circle:shape@end//circle @implementation circle-(void) Setfillcolor: (Shapecolor) c {if ( c = = Kredcolor) {c = Kgreencolor; }[Super SETFILLCOLOR:C]; Sends a message to a super-class shape, and the superclass executes its Setfillcolor method. } @end//circle3.2 For example: self = [super init]; The function is to enable the superclass NSObject to complete its initialization work. And if you return a new object, you need to update self.
The use of square brackets [] objective-c understanding