在搜索名称中带有 CR 的一些缺失库时,我开始想知道https://github.com/croberts22/CRNavigationController或其他一些框架中的“CR”背后的遗产是什么?
它与引用计数有关吗?或者是别的什么?
在搜索名称中带有 CR 的一些缺失库时,我开始想知道https://github.com/croberts22/CRNavigationController或其他一些框架中的“CR”背后的遗产是什么?
它与引用计数有关吗?或者是别的什么?
看到作者的名字是 Corey Roberts,我猜这就是原因。
是的,它是类前缀。这些是在每个项目的基础上设置的,当你在 Xcode 中启动一个新项目时,系统会提示你设置一个类前缀。
这是 Apple 关于类前缀的官方说法:
Your own classes should use three letter prefixes. These might relate to a combination of your company name and your app name, or even a specific component within your app. As an example, if your company were called Whispering Oak, and you were developing a game called Zebra Surprise, you might choose WZS or WOZ as your class prefix.
更多内容可以在 Objective-C 编程:约定页面上找到。
这是一个命名约定。在 Objective-C 中,我们没有命名空间(就像在 C++ 中一样),因此为了避免名称冲突,库的作者将它们的首字母添加为类的前缀。