void *和id有什么区别?(What's the difference between void* and id? [duplicate])

系统教程 行业动态 更新时间:2024-06-14 16:57:39
void *和id有什么区别?(What's the difference between void* and id? [duplicate])

可能重复: id和void之间的客观c差异*

例如,UIView动画委托回调方法有这个参数:

context:(void*)context

为什么不简单地ID? 如果我不关心上下文,我总是通过零。 但是当我想要一个时,我传递了这个对象。 有什么不同? 为什么他们更喜欢void * over id?

Possible Duplicate: objective c difference between id and void *

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

context:(void*)context

Why not simply id? I always pass nil if I don't care about an context. But when I want one, I pass the object. What's the difference? Why did they prefer void* over id?

最满意答案

id是一个指向具有isa指针的结构的指针(它指向ObjectiveC运行时,这个“thing”是对象)。 void*只是指向可能的任何东西(可能是另一个id )的指针。

id is a pointer to a struct which has isa pointer (which denotes to ObjectiveC runtime that this "thing" is object). void* is simply a pointer to possibly anything (probably another id).

更多推荐

本文发布于:2023-04-13 12:05:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/76f6878689d9eb0f089d1a9b6e995d68.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:有什么区别   id   void   difference   duplicate

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!