Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Objective-C Properties - what does "id" mean? [duplicate]

Possible Duplicate:
What is the meaning of id?

Per my question I'm obviously a noob at iOS development and Objective-C. I was following a tutorial and I have this line declared in my interface (.h) implementation:

@property (strong, nonatomic) id dataObject1;

What does the "id" mean?

like image 496
ScoobaSteve Avatar asked Jan 10 '13 22:01

ScoobaSteve


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

What is properties in Objective-C?

Objective-C properties offer a way to define the information that a class is intended to encapsulate. As you saw in Properties Control Access to an Object's Values, property declarations are included in the interface for a class, like this: @interface XYZPerson : NSObject.


1 Answers

id is the type of the object; the type could have been NSArray * or int instead, for example.

The id type specifies a reference to any Objective-C object (no matter its class).

like image 91
praseodym Avatar answered Sep 30 '22 16:09

praseodym