The Cocoa (Application) layer includes the frameworks described in the following sections.
Cocoa in the architecture of OS X
![](https://img-my.csdn.net/uploads/201211/22/1353551025_8711.jpg)
Cocoa Umbrella Framework
The Cocoa umbrella framework (Cocoa.framework
) imports the core Objective-C frameworks for app development: AppKit, Foundation, and Core Data.
-
AppKit (
AppKit.framework
). This is the only framework of the three that is actually in the Cocoa layer. See “AppKit” for a summary of AppKit features and classes. -
Foundation (
Foundation.framework
). The classes of the Foundation framework (which resides in the Core Services layer) implement data management, file access, process notification, network communication, and other low-level features. AppKit has a direct dependency on Foundation because many of its methods and functions either take instances of Foundation classes as parameters, or return the instances as values.To find out more about Foundation, see “Foundation and Core Foundation.”
-
Core Data (
CoreData.framework
). The classes of the Core Data framework (which also resides in the Core Services layer) manage the data model of an app based on the Model-View-Controller design pattern. Although Core Data is optional for app development, it is recommended for apps that deal with large data sets.For more information about Core Data, see “Core Data.”
AppKit
Game Kit
The Game Kit framework (GameKit.framework
) provides APIs that allow your app to participate in Game Center. For example, you can use Game Kit classes to display leaderboards in your game and to give users the opportunity to share their in-game achievements and play multiplayer games.
To learn more about using Game Kit in your app, see Game Kit Framework Reference.
Preference Panes
The Preference Panes framework (PreferencePanes.framework
) lets you create plug-ins containing a user interface for setting app preferences. At runtime, the System Preferences app (or your app) can dynamically load the plug-in and present the settings UI to users. In System Preferences, each icon in the Show All view represents an individual preference pane plug-in. You typically implement preference pane plug-ins when your app lacks its own user interface or has a very limited UI but needs to be configurable. In these cases, you create both the plug-in and the app-specific code that reads and writes the preference settings.
For more information about creating preference-pane plug-ins, see Preference Pane Programming Guide.
Screen Saver
The Screen Saver framework (ScreenSaver.framework
) contains classes for creating dynamically loadable bundles that implement screen savers. Users can select your screen saver in the Desktop & Screen Saver pane of the System Preferences app. Screen Saver helps you implement the screen saver view and preview and manage screen saver preferences.
To learn more about creating screen savers, see Screen Saver Framework Reference. Also read the technical note Building Screen Savers for Snow Leopard for additional information.
Security Interface
The Security Interface framework (SecurityInterface.framework
) contains classes that provide UI elements for programs implementing security features such as authorization, access to digital certificates, and access to items in keychains. There are classes for creating custom views and standard security controls, for creating panels and sheets for presenting and editing certificates, for editing keychain settings, and for presenting and allowing selection of identifies.
For more information about the Security Interface framework, see Security Interface Framework Reference.
总括
The Cocoa frameworks consist of libraries, APIs, and runtimes that form the development layer for all of Mac OS X. By developing with Cocoa, you will be creating applications the same way Mac OS X itself is created. Your application will automatically inherit the great behaviors and appearances of Mac OS X, with full access to the underlying power of the UNIX operating system. Using Cocoa with the Xcode IDE is simply the best way to create native Mac applications.
Audio and Video
Core Audio
Core MIDI
Core Video
Data Management
Core Data
Networking and Internet
Bonjour
Directory Services
Kerberos
Graphics and Animation
Core Animation
Core Image
OpenGL
Quartz
QuickTime
QTKit
Cocoa Bridges to
Scripting Languages
AppleScript
Python
Ruby
User Applications
Address Book
Calendar Store
Instant Message
The Cocoa Touch frameworks that drive iOS apps share many proven patterns found on the Mac, but were built with a special focus on touch-based interfaces and optimization. UIKit provides the basic tools you need to implement graphical, event-driven applications in iOS. UIKit builds on the same Foundation framework infrastructure found on the Mac OS X, including file handling, networking, string building, and more.
The unique interface of iOS means that Cocoa Touch has a unique design to match. Using UIKit you have access to the special GUI controls, buttons, and full-screen views on iOS. You also get to control your application with the accelerometer and the multi-touch gesture.
Audio and Video
Core Audio
OpenAL
Media Library
AV Foundation
Data Management
Core Data
SQLite
Graphics and Animation
Core Animation
OpenGL ES
Quartz 2D
Networking and Internet
Bonjour
WebKit
BSD Sockets
User Applications
Address Book
Core Location
Map Kit
Store Kit