Chapter 12 in brief


#1

Object: An object is like a structure in that it holds it data. However, unlike a structure, an object also contain a set of functions that act upon that data. To trigger oe of these functions, you send a message to the object.
Method: A function that is triggered by a message is known as a method.
How O-C was designed? In the early 1980’s, Brad Cox & Tom Love decided to add object-orientred ideas to the C language. For the object, they built upon the idea of structs allocated on the heap and added a message-sending syntax. The result was the language O-C.
Class: A class describes a particular type of object. This description includes methods & instance variables where an object of this type stores it data. You ask a class to create an object of its type for you on the heap. We say that the resulting object is an instance of that class. For instance CLLocation.
Suffix .m: Files containing O-C code are typically given the suffix .m.
NSLog: NSLog() is an O-C function(not a method) not unlike printf(); it takes format truing, replaces % tokens with actual values, and writes the result to the console. However, its format string always begin with an @, and it dose not require a \n at the end.
%@: %@ asks the object to describe itself as a string.
Message Anatomy: A message send is always surrounded by square brackets, and it always has at least two pars: 1- A pointer to the object that is receiving the message. 2- the name of the method to be triggered. message send can also have arguments.
Receiver: THe object that is receiving the message is known as the receiver.
Selector: The method name is known as the selector.
id: When declaring a pointer to hold on to an object, most f the time we specify the class of the object that the pointer will refer to. However, often we need a way to create a pointer without knowing exactly what kind of object the pointer will refer to. For this case, we use the type id to mean “a pointer to some kind of O-C object”. Note that id implies the asterisk.