Reputation: 11452
I am bit confused, as my title mentioned,
Is id
in Objective C is primitive data type? or Object type? I always thought that id
is Object type as it is pointing towards an object.
So, Is it Object type or Primitive data type?
Upvotes: 4
Views: 1564
Reputation: 3328
Definitly not a primitive type. From Apple:
In Objective-C, object identifiers are of a distinct data type: id. This type is the general type for any kind of object regardless of class and can be used for instances of a class and for class objects themselves.
Upvotes: 5
Reputation: 214969
id
is declared in objc.h as
typedef struct objc_object {
Class isa;
} *id;
so yes, I'd say it's primitive (pointers are primitive types in C).
Upvotes: 4
Reputation: 5792
I believe that 'id' from Objective-C is a similar type to void pointer from plain 'c'. As pointers are primitives I would guess that 'id' is indeed a primitive type.
Upvotes: 1