kCF 前缀是什么意思?

What does the kCF prefix mean?

CoreFoundation 中的许多常量都有 kCF 前缀。这是什么意思?

k 代表 Constant & CF 代表 Core Foundation

OS X FrameworksiOS Frameworks 您会找到系统框架列表以及框架的 类、方法、函数、类型或常量使用的键前缀。

此列表包含

Name                      Prefix
--------------------------------
...
CFNetwork.framework       CF
...
CoreFoundation.framework  CF
...

所以实际上有几个框架使用"CF"前缀,但是 核心基础是最"prominent"一个。

常量的 "k" 前缀记录在 Naming Conventions 在 "Introduction to Core Foundation Design Concepts" (强调已添加):

A major programming-interface convention in Core Foundation is to use the name of the opaque type that is most closely related to a symbol as the symbol’s prefix. For functions, this prefix identifies not only the type to which the function “belongs” but usually the type of object that is the target of the function’s action. (An exception to this convention are constants, which put “k” before the type prefix.)

例如,kCFAllocatorMalloc是一个与 CFAllocator type 是 Core Foundation 框架的一部分。