Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is a (void *) parameter

Tags:

objective-c

I've recently seen a delegate method (that appears to work) and looks like this:

-(void) doSomethingWithThisPieceOfData:(void *)theData;

The delegate method then casts theData as:

-(void) doSomethingWithThisPieceOfData:(void *)theData { anObject *myObject; myObject = (anObject)theData; .... }

Why does this work and is it good coding practice? I would have used (id *)theData instead.

thanks.

like image 239
jangelo42 Avatar asked May 24 '26 12:05

jangelo42


1 Answers

void * as a type indicates that any pointer can be passed, and that the code that recieves it will cast it to whatever type it considers appropriate.

like image 161
Paul Sonier Avatar answered May 26 '26 03:05

Paul Sonier