Apple
describes the technologies implemented within the iOS as a series of
layers, with each layer being made up of different frameworks that can
be used in your applications. As you might expect, the Cocoa Touch
layer is at the top (see Figure 1).
Let’s review some of the most important frameworks that make up each of the layers. If you want a comprehensive guide to all frameworks, just search for each layer by its name in the Apple Xcode documentation.
By the Way
Apple has
included three important frameworks in every iOS application template
(CoreGraphics, Foundation, and UIKit). These frameworks are all that is
needed for simple iOS applications and will cover most of what you do
in this book. When additional frameworks are needed, I describe how to
include them in your projects.
The Cocoa Touch Layer
The Cocoa Touch
layer is made up of several frameworks that will provide the core
functionality for your applications – including multitasking and
advertising in iOS 4.x. UIKit could be described as the “rock
star"—delivering much more than the UI in its name implies.
UIKit
UIKit covers a wide range of
functionality. It is responsible for application launching and
termination, controlling the interface and multitouch events, and
providing access to common views of data (including web pages and Word
and Excel documents, among others).
UIKit is also
responsible for many intra-iPhone integration features. Accessing the
Media Library, Photo Library, and accelerometer is also accomplished
using the classes and methods within UIKit.
Map Kit
The Map Kit
framework enables developers to add Google Map views to any
application, including annotation, location, and event-handling
features.
Game Kit
The Game Kit framework adds
network-interactivity to iPhone applications. Game Kit supplies
mechanisms for creating and using peer-to-peer networks, including
session discovery, mediation, and voice chat. These features can be
added to any application, game or not!
Message UI/Address Book UI
Apple is sensitive to the
need for integration between iOS applications. The Message UI and
Address Book UI frameworks can be used to enable email composition and
contact access from any application you develop.
iAd
The iAd framework
supports the addition of ads to your applications. iAds are interactive
advertising pieces that can be added to your software with a simple
drag and drop. You do not need to manage iAds interactions in your
application – Apple does this for you.
The Media Layer
When Apple makes a
computing device, you’d better believe that they put some thought into
the media capabilities. The iPhone can create complex graphics, play
back audio and video, and even generate real-time 3D graphics. The
Media layer’s frameworks handle it all.
AV Foundation Framework
The AV Foundation Framework can
be used to managing complex sound and video playback and editing. This
should be used for implementing advanced features, such as movie
recording, track management, and audio panning.
Core Audio
The Core Audio
framework exposes methods for handling basic playback and recording of
audio on the iPhone. It includes the AudioToolbox framework, which can
be used for playing alert sounds or generating short vibrations, and
the AudioUnit.framework for processing sounds.
Core Graphics
Use the Core Graphics
framework to add 2D drawing and compositing features to your
applications. Although most of this book will use existing interface
classes and images in its applications, you can use core graphics to
programmatically manipulate the iPhone’s view.
Core Text
Provides precise positioning
and control over text that is displayed on the iPhone screen. Core Text
should be used in mobile text-processing applications and software that
requires high-quality and fast presentation and manipulation of styled
text.
Image I/O
The Image I/O framework can be
used to import and export both image data and image metadata for any
file format supported by iOS.
Media Player
The Media Player
framework provides you, the developer, with an easy way to play back
movies with typical onscreen controls. The player can be invoked
directly from your application.
OpenGL ES
OpenGL ES is a subset
of the popular OpenGL framework for embedded systems (ES). OpenGL ES
can be used to create 2D and 3D animation on the iPhone. Using OpenGL
requires additional development experience beyond Objective-C, but can
generate amazing scenes for a handheld device—similar to what is
possible on modern game consoles.
Quartz Core
The Quartz Core framework
is used to create animations that will take advantage of the hardware
capabilities of your iPhone. This includes the feature set known as
Core Animation.
The Core Services Layer
The Core Services layer is
used to access lower-level operating system services, such as file
access, networking, and many common data object types. You’ll make use
of core services frequently by way of the Foundation framework.
Address Book
The Address Book
framework is used to directly access and manipulate address book
information. This is used to update contact information and/or use it
within your applications.
CFNetwork
The CFNetwork framework provides access to BSD sockets, HTTP and FTP requests, and Bonjour discovery.
Core Data
The Core Data framework can be
used to create the data model of an iOS application. Core Data provides
a relational data model based on SQLite, and can be used to bind data
to interface objects to eliminate the need for complex data
manipulations in code.
Core Foundation
Core Foundation provides much
of the same functionality of the Foundation framework, but is a
procedural C framework, and therefore requires a different development
approach that is, arguably, less efficient than Objective-C’s
object-oriented model. You should probably avoid Core Foundation unless
you absolutely need it.
Foundation
The Foundation
framework provides an Objective-C wrapper around features in Core
Foundation. Manipulation of strings, arrays, and dictionaries is
handled through the Foundation framework, as are other fundamental
application necessities, including managing application preferences,
threads, and internationalization.
Event Kit
The Event Kit framework
be used to access calendar information stored on the iOS device. It
also enables the developer to create new events within a calendar,
including alarms.
Core Location
The Core Location framework can
be used to obtain latitude and longitude information from the iPhone’s
GPS (WiFi-based location service in the original iPhone) along with a
measurement of precision.
Core Motion
The Core Motion framework
manages most motion-related events on the iOS platform, such as using
the accelerometer or the new gyroscope of the iPhone 4. Core Motion is
new to iOS 4, but the features have been available in earlier versions
of the OS.
Quick Look
The Quick Look framework
implements file viewing within an application, even if the application
does not “know” how to open a specific file type. This is intended for
viewing files downloaded to the device.
Store Kit
The Store Kit
framework enables developers to create in-application transactions for
purchasing content without exiting the software. All interactions take
place through the App Store, so no financial data is requested or
transmitted through the Store Kit methods.
System Configuration
Use the System
Configuration framework to determine the current state of the iPhone’s
network configuration—what network it is connected to (if any) and what
devices are reachable.
The Core OS Layer
The Core OS layer, as you’d
expect, is made up of the lowest-level services in the iOS. These
features include threads, complex math, hardware accessories, and
cryptography. You should only need to access these frameworks in rare
circumstances.
Accelerate
The Accelerate
framework simplifies complete calculations and large-number
manipulation. This includes digital signal processing capabilities.
External Accessory
The External Accessory framework is used to develop interfaces to accessories connected via the dock connector or Bluetooth.
Security
The Security
framework provides functions for performing cryptographic functions
(encrypting/decrypting data). This includes interacting with the iOS
keychain to add, delete, and modify items.
System
The System framework
gives developers access to a subset of the typical tools they would
find in an unrestricted UNIX development environment.