What is the difference between void * and id?

Possible duplicate:
target c is the difference between id and void *

For example, the UIView animation delegate callback method has this argument:

context:(void*)context

Why not just specify id? I always pass zero if I don't need context. But when I want it, I pass the object. Who cares? Why do they prefer void * over id?

+3
source share
3 answers

id is a pointer to a structure that has a pointer isa(which indicates the ObjectiveC runtime, that this "thing" is an object). void*- it’s just a pointer to possibly anything (perhaps one more id).

+7

, . obj-c, , , . void * - , " ".

, . NULL, .

+2

, , id void *. , , .

void *, . , . . , . , , , : .

Being emptiness * allows you to do a lot. You can pass a standard objective-c object. You can pass a simple C-style data structure. You can pass a pointer to a function. You can skip zero and do nothing.

+2
source

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


All Articles