What is the purpose of the CoreFoundation framework?

Just a coder picture Just a coder · Jul 11, 2012 · Viewed 8.2k times · Source

I have been programming in Objective-C Cocoa for a little while using NSObjects etc. I see that there is another framework: CoreFoundation.As i look it over, it seems to be a C-Style framework.

So I have some curiosities i'd like clarified. I've googled but found no direct answer.

  1. What is the purpose of CoreFoundation framework?
  2. Doesn't the Cocoa Framework provide every thing that's needed already?
  3. Does the CoreFoundation Framework provide any advantages that the CocoaFramework does not provide?

These are some of the questions i have. If anyone can provide an answer, or provide me with resources to read about it, that would be great. I am wondering if its worth learning more about the framework.

Answer

Matt Wilding picture Matt Wilding · Jul 11, 2012

CoreFoundation is more than just a C-based alternative to Foundation. In way over-simplified terms, Foundation essentially is CoreFoundation, since one is built on top of the other. Many of the classes in Foundation are just lightweight Objective C wrappers around their CoreFoundation counterpart, which is how toll-free bridging works (ex. CFString and NSString).

For more history, and a much more technical explanation, see this article.

If you actually want to read the CoreFoundation source, several versions of Apple's "CFLite" framework are available for reference here.