TeaCupApp
TeaCupApp

Reputation: 11452

Is id in Objective C is primitive data type

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

Answers (3)

san
san

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

georg
georg

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

Kris
Kris

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

Related Questions