What is a parameter (void *)

I recently saw a delegate method (which seems to work) and looks like this:

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

Then the delegate method distinguishes Data as:

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

Why does this work, and is it good coding practice? Instead, I would use (id *) theData.

thank.

+3
source share
2 answers

void * as a type indicates that any pointer can be passed, and that the code that receives it will distinguish it from any type that it considers appropriate.

+4
source

, , , . , .

, - , , , , .

void . , , . .

SO .

0

Source: https://habr.com/ru/post/1773311/


All Articles