I noticed that there are variables and functions used by many libraries that start with CF and ends with Ref, like: CFStringRef , CFURLRef , CFHTTPMessageCreateRequest , etc …
1) what does CF stand for ? I don’t know why apple does not say a word about such abbreviations.
2) what’s the benefit(s) of using (for ex.) CFStringRef instead of using NSString ?
3) if it’s better to use these CF variables, should I then replace all regular variable like NSString with CFStringRef ?
CFstands for Core Foundation. If you’re interested in learning more about that, you can start by reading the Core Foundation Design Concepts Guide. There are also the String Programming Guide for Core Foundation and Collections Programming Topics for Core Foundation, which will tell you more aboutCFStringRefand the various collection types (arrays, dictionaries, and so forth).Basically, Core Foundation is a relatively low-level framework that does some of the same things that Foundation does, but is written in C, and not Objective-C. Some Core Foundation “classes” (they’re not really classes) are also “toll-free bridged” with their Objective-C counterparts, for example, it is possible to cast a
CFStringRefto anNSString *(though it is a little more complicated with ARC).If you don’t need specific APIs that are only available in Core Foundation, there’s absolutely no need to use it instead of Foundation. Core Foundation code tends to be less readable than Objective-C and also makes memory management a bit more complicated.
However, it can be quite useful to familiarize oneself with the basic concepts of Core Foundation, because there are still quite a few other frameworks that are built similarly. Core Text and Core Graphics are examples – while they don’t formally belong to Core Foundation, they use the same naming and memory management conventions. There are also some APIs that are only available in Core Foundation and don’t have Foundation counterparts –
CFBagReforCFBitVector(both collection types) would be examples.