为什么 Apple 不让私有 API 变得不可访问?
如果 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
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.
简而言之,他们不会将它们标记为私有,因为他们根本没有描述它们。
您不应该发送的消息不会出现在 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.