Chapter 27: Building a (Core) Foundation
As an iOS developer, you will spend most of your time using the UIKit and Foundation frameworks. UIKit provides user interface elements like UIView
and UIButton
. Foundation provides basic data structures like NSArray
and NSDictionary
. These can handle the vast majority of problems the average iOS application will encounter. But some things require lower-level frameworks. The names of these lower-level frameworks often start with the word “Core,” Core Text, Core Graphics, and Core Video, for example. What they all have in common are C-based APIs based on Core Foundation.
Core Foundation provides a C API that is similar to the Objective-C Foundation framework. It provides a consistent object model with reference counting and containers, just like Foundation, and simplifies passing common data types to low-level frameworks. As you see later in this chapter, Core Foundation is tightly coupled with Foundation, making it easy to pass data between C and Objective-C.
In this chapter, you find out about the Core Foundation data types and naming conventions. You learn about Core Foundation allocators and how they provide greater flexibility than +alloc
provides in Objective-C. This chapter covers Core Foundation string and binary data types extensively. You discover Core Foundation collection types, which are more flexible than their Foundation counterparts and include some not found in Objective-C. Finally, you learn how to move data easily between ...