Reputation: 5344
I have a function that returns "id". Does this include a return of void? (as in nothing) Or does "id" require some kind of object/variable?
Upvotes: 1
Views: 503
Reputation: 23390
'id' is a pointer to an instance of an Objective-C class. So your method can return a pointer to an instance, or 'nil' (a zero pointer).
Upvotes: 1
Reputation: 726499
In Objective C, id
means object of any type
, akin to void*
in C/C++. You can return nil
for from a function returning id
to indicate that you do not want to return anything in particular.
Upvotes: 1
Reputation: 124997
In Objective-C, id
is a keyword that represents an untyped object pointer. It's kinda like void*, the untyped pointer, but it adds the restriction that the pointer must point to some sort of Objective-C object.
Upvotes: 4
Reputation: 3467
id
is a general data type that can wrap most objects. If you can, you usually want to opt for coding specific data types, but if the situation (in a method for example) can use a wide range of data types, id
is used.
This Stackoverflow post should help to explain what it is and when to use it. A simple Google search will also turn up information.
Upvotes: 1