为什么 Apple 不让私有 API 变得不可访问?

发布于 2024-08-29 12:12:44 字数 166 浏览 2 评论 0原文

如果 Apple 不希望开发人员在 iPhone SDK 中使用私有 API,那么他们为什么不使用与 C# 的“internal”关键字等价的 Objective-C 来标记类和/或方法呢?如果 API 分布在多个二进制文件中,Apple 可以将它们重构为专用的仅限私有 API 的二进制文件,以使这对他们来说更容易。

If Apple doesn't want developers using private APIs in the iPhone SDK, why don't they do something like mark the classes and/or methods with whatever the Objective-C equivalent of C#'s "internal" keyword? If the APIs are spread amongst multiple binaries, Apple could refactor them into dedicated private-API-only binaries to make this easier for them.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

只为守护你 2024-09-05 12:12:44

Objective-C 没有与 C# 的“internal”或 Java 的“final”关键字等效的关键字。我认为这与语言的动态特性有关,无论如何,任何此类功能都太容易解决。

另外,对于iPhone SDK,所有库都需要静态编译到应用程序中,不允许动态链接。因此,即使可能,将函数设置为“内部”也不会影响可见性。

Objective-C doesn't have an equivalent for the C#'s "internal" or Java's "final" keywords. I think it's to do with the dynamic nature of the language, that any such functionality would be too easily worked around anyway.

Also regarding the iPhone SDK, all the libraries need to be statically compiled into the aplication, no dynamic linking allowed. So setting a function as "internal" would make no difference in visibility even if it was possible.

夜声 2024-09-05 12:12:44

简而言之,他们不会将它们标记为私有,因为他们根本没有描述它们。

您不应该发送的消息不会出现在 SDK 中相应的 .h 文件中。

私有 API 通常是由人们使用类转储等工具针对二进制框架找到的,而不是通过读取标头。

Short answer, they don't mark them as private because they don't describe them at all.

Messages you aren't supposed to send don't appear in the corresponding .h files in the SDKs.

Private APIs are typically found by people using tools like class-dump against the binary frameworks, not by reading headers.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文