Interesting Void


Near the end of the chapter, Using Alert Panels, the method for alrtEnded:code:context: uses an argument of type (void *), the asterix suggesting that the void is some sort of reference.



A variable of type void * is used to store the address of something whose type is not needed.

For example:

- (void)handleEvent:(EventType)event inContext:(void *)con
   MyContext * context = (MyContext *)con;

The caller of handleEvent:inContext: does not need to know the exact type of the context, but the receiver does need to know if it wants to do something with the context.

void * is also known as an opaque data type, and it is used to reduce type-related dependencies between different parts in program source files.


Cheers. That explains all.