O'Reilly logo

Cocoa in a Nutshell by James Duncan Davidson, Michael Beam

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 2. Foundation

The Foundation framework provides support for a variety of basic functionalities and data types, including the following:

  • Strings, numbers, and collections

  • Dates and time

  • Binary data

  • Means of working with files, including accessing data and working with bundles

  • Distributed event notification

  • Operating system interaction

  • Threading

This chapter discusses these subjects and provides several short examples that demonstrate of the most common methods of the key classes.

Data

The Foundation framework provides many classes and protocols that extend the capabilities of the Objective-C language to represent and work with basic data types, such as strings and numbers, in an object-oriented fashion. Additionally, the Foundation framework provides application programming interfaces (APIs) for working with more complex data types, such as dates and collections.

Immutable Versus Mutable Classes

Classes such as NSString and NSArray are immutable classes; instances of these classes cannot be altered after they are initialized. Each immutable class, however, has a mutable subclass: for example, NSString has the mutable subclass NSMutableString, and NSArray has the subclass NSMutableArray. Mutable subclasses extend their superclass’s functionality to allow modification after initialization. Immutable classes are more efficient, but mutable classes are more flexible.

Basic Types

Two of the most basic data types in an application are strings and numbers . The Foundation framework provides ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required