Many constants in CoreFoundation have the kCF prefix. What does it mean?
-
"[…] constants in CoreFoundation" – well, just that. `k` for "constant", `CF` for "CoreFoundation". – The Paramagnetic Croissant Jul 27 '15 at 06:22
-
@TheParamagneticCroissant Any references? Thanks. – Allen Jul 27 '15 at 06:28
2 Answers
In both OS X Frameworks and iOS Frameworks you find a list of system frameworks together with the key prefixes used by the classes, methods, functions, types, or constants of the framework.
This list contains
Name Prefix -------------------------------- ... CFNetwork.framework CF ... CoreFoundation.framework CF ...
So there are actually several frameworks using the "CF" prefix, but Core Foundation is the most "prominent" one.
The "k" prefix for constants is documented in Naming Conventions in "Introduction to Core Foundation Design Concepts" (emphasis added):
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.)
As an example, kCFAllocatorMalloc
is a constant related to
the CFAllocator
type which is part of the Core Foundation framework.

- 529,903
- 94
- 1,240
- 1,382
k
stands for Constant
& CF
stands for Core Foundation

- 6,318
- 1
- 26
- 40
-
-
I'm a little curious about that why don't use first characters `c` of constant. – Allen Jul 27 '15 at 06:30
-
-
check the definition... (An exception to this convention are constants, which put “k” before the type prefix.) – Gobi M Sep 18 '15 at 10:56
-
discussion for 'k' naming - http://stackoverflow.com/questions/9064794/what-does-the-k-stand-for-in-cocoa-constant-names – Gobi M Sep 18 '15 at 11:00