Type id
The id data type is used to store an object of any type. In a sense, it is a generic object type. For example, this line declares graphicObject to be a variable of type id:
id graphicObject;
Methods can be declared to return values of type id, like so:
-(id) newObject: (int) type;
This declares an instance method called newObject that takes a single integer argument called type and returns a value of type id.
The id data type is an important data type used often in this book. We mention it in passing here for the sake of completeness. The id type is the basis for very important features in Objective-C known as polymorphism and dynamic binding, which Chapter 9, “Polymorphism, Dynamic Typing, and Dynamic Binding,” discusses extensively. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access