Chapter 5
The Cocoa Foundation Framework
What You Will Learn In This Chapter:
- Building the interface for an iOS game by using Interface Builder
- Designing an iOS game by using the Model-View-Controller architecture
- Handling text with NSString
- Working with mutable and immutable types
- Using collections to store data
- Calling periodic methods with NSTimer
In the previous two chapters, you learned about the languages that you use to build games for iOS. You may remember using the #import statement in the programs in the last chapter to include classes from the Cocoa Foundation framework like NSString. In this chapter, you will take a closer look at some of the important classes that make up the Foundation framework. You will also begin developing games for iOS, leaving command-line games behind.
The Foundation framework provides many low-level classes that you will use in every iOS program, hence the name Foundation. Foundation includes object-oriented versions of base types like strings and dates, collections like arrays, dictionaries, and sets, along with utility classes for working with I/O, URLs, and timers. Foundation also includes the root class NSObject that you used to create your own classes in the last chapter.
Model-View-Controller Architecture
Before I move on with the sample, it is important that you understand the basic architecture used to build most iPhone applications: Model-View-Controller. There are three parts to the architecture, shown in Figure 5.1. As you can ...