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?
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.
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.
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.
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.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With