An id is an Objective C type used to hold a reference to any Objective C object.
Object Initialization, the alloc method allocates storage for an object and set its instance variables to zero. NSObject implements an init method that provides the foundation for initialization.
Message Dispatch, messaging is fundamental concept in OOP. It is mechanism used to invoke a method on an object. The receiving object of a message determines at runtime which of its instance method to invoke. Instance methods have access to an object's instance variables along with its instance method.
[orderObject addItem:burgerObject forPrice:3.5];
orderObject is the object the message is sent to, addItem: forPrice: information identifies the method's actual name.
Message Forwarding enables an object to perform user-defined processing when it receives a message not mapped to its set of methods. Message forwarding can be used to provide many of features typically associated with OOP multiple inheritance. There are two types of message forwarding
- Fast forwarding can implement fast forwarding by overriding the NSObject forwardingTargetForSelector: method to forward the method to another object. This technique makes it appear like the implementations of your object and the forwarding object are combined. This simulates the behavior of multiple inheritance of class implementations. It works well if you have a target class that defines all the possible messages that your object can consume.
- Normal forwarding can implement normal forwarding by overriding the NSObject forwardInvocation: method. This technique enables your object to use the full contents of the message (target, method name, parameters).