Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 757
TeaCupApp Avatar asked Dec 27 '22 22:12

TeaCupApp


2 Answers

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.

like image 96
san Avatar answered Jan 14 '23 17:01

san


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).

like image 37
georg Avatar answered Jan 14 '23 18:01

georg