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