Understanding Foundation Kit

The Foundation Kit framework that comes with Cocoa (officially it's got the Kit appended to it, but not many people bother) provides us with a number of basic utility classes, which were originally written to extend the Objective C programming language. These include strings, arrays, sets, dictionaries, and dates, for example.

Some of the more basic classes are, strictly speaking, no longer needed for Swift development, since Swift already provides support for strings, text, and collections such as dictionaries and arrays. However, we will see later that they can often be of use to us. Foundation is baked into the core of Cocoa, so we will need to make use of most of what it has to offer.

Then there are a larger number of classes that go way beyond basic data types and structures, such as those providing us with classes for network connectivity, notifications, threading, user defaults, and many others.

In addition to its classes, Foundation also defines a number of protocols that we use frequently, including the NSObject and NSKeyValueObserving protocols, both of which we'll be looking at more closely in this chapter.

Another aim of Foundation is to encapsulate a range of technologies that can be used across all of Apple's platforms, thus enhancing portability. Although Cocoa provides us with many user interface elements, which are generally not portable across platforms, it should not be forgotten that there are extensive amounts of Cocoa code that reside under the hood, and which use frameworks that would be equally at home on iOS, tvOS, or of course, macOS.