Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Objective-C: Why is it called 'id'?

Tags:

objective-c

Why is the Objective-C object type called 'id'? As opposed to, say, 'object'?

like image 387
Jeff Avatar asked Jan 30 '09 00:01

Jeff


People also ask

What is an id in Objective-C?

id is the generic object pointer, an Objective-C type representing "any object". An instance of any Objective-C class can be stored in an id variable.

What is id in C?

In C language, an identifier is a combination of alphanumeric characters, i.e. first begin with a letter of the alphabet or an underline, and the remaining are letter of an alphabet, any numeric digit, or the underline.

What is id in Objective-C in Swift?

In Swift 3, the id type in Objective-C now maps to the Any type in Swift, which describes a value of any type, whether a class, enum, struct, or any other Swift type.

What is the primary use of the id type in Objective-C?

Dynamic typing allows us to declare a variable that is capable of storing any type of object, regardless of its class origins. This is achieved using the Objective-C id type. The idtype is a special, general purpose data type that can be assigned an object of any type.


Video Answer


1 Answers

It is called id because that, literally, is all the type represents - an identifier.

Quoting Brad Cox from Object Oriented Programming: an Evolutionary Approach (actually, the first edition, one of the first OO books I bought): An id consumes a fixed amount of space, wide enough to identify as many objects as may exist at any one time. This space is not the same as the space occupied by the private data in the object itself. Object identifiers are fixed-sized numbers,...

like image 164
Andy Dent Avatar answered Sep 21 '22 10:09

Andy Dent