Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
In standard C, you’d perform two function calls to allocate and initialize data. Here is how that might look, in contrast to Objective-C’s [[Car alloc] init] statement:
Car *myCar = malloc(sizeof(Car));
init(myCar);
Objective-C doesn’t use function_name(arguments) syntax. Instead, you send messages to objects using square brackets. Messages tell the object to perform a method. It is the object’s responsibility to implement that method and produce a result. The first item within the brackets is the receiver of the message; the second item is a method name, and possibly some arguments to that method that together define the message you want sent. In C, you might write
printCarInfo(myCar);
but in Objective-C, you say: