OSX Technology Overview

135
Mac Technology Overview

Transcript of OSX Technology Overview

Page 1: OSX Technology Overview

Mac TechnologyOverview

Page 2: OSX Technology Overview

Contents

About the Technologies for Developing Mac OS X Software 8At a Glance 9

Mac OS X Has a Layered Architecture with Key Technologies in Each Layer 9You Can Create Many Different Kinds of Software for Mac OS X 10When Porting a Cocoa Touch App, Be Aware of the Similarities and Differences in API 11

Tools to Help You Develop Software for Mac OS X 11Information to Help You Develop Software for Mac OS X 12

Software Product Types 13Apps 13Frameworks 13Plug-ins 14

Address Book Action Plug-Ins 14Application Plug-Ins 15Automator Plug-Ins 15Contextual Menu Plug-Ins 15Core Audio Plug-Ins 16Image Units 16Input Method Components 16Metadata Importers 16Safari Plug-ins 17

Safari Extensions 17Dashboard Widgets 17Agent Applications 18Screen Savers 18

Slideshows 18Programmatic Screen Savers 19

Services 19Preference Panes 19Web Content 20

Dynamic Websites 20SOAP, XML-RPC, and Web Services 20

Mail Stationery 21Command-Line Tools 21

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

2

Page 3: OSX Technology Overview

Launch Items and Daemons 21Scripts 22Scripting Additions for AppleScript 23Kernel Extensions 23Device Drivers 24

Cocoa Application Layer 25High-Level Features 25

Resume 26Full-Screen Mode 27Cocoa Auto Layout 28Popovers 28Software Configuration 29Accessibility 29AppleScript 30Spotlight 30Ink Services 31

Frameworks 31Cocoa Umbrella Framework 31AppKit 32Preference Pane 33Screen Saver 33Security Interface 34

Media Layer 35Supported Media Formats 35Graphics Technologies 36

Graphics and Drawing 36Text, Typography, and Fonts 37Images 38Color Management 38Printing 39

Audio Technologies 40Video Technologies 40Media Layer Frameworks 41

Application Services Umbrella Framework 41AV Foundation 43ColorSync 43Core Audio 43Instant Messaging 45

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

3

Contents

Page 4: OSX Technology Overview

OpenAL 45OpenGL 45Quartz 46Quartz Core 47QuickTime Kit 49Other Media Layer Frameworks 49

Core Services Layer 51High-Level Features 51

iCloud Storage 52Automatic Reference Counting 53File Coordination 53Bundles and Packages 54Internationalization and Localization 54Blocks 55Grand Central Dispatch 55Bonjour 56Security Services 56Speech Technologies 57Identity Services 58Time Machine Support 58Keychain Services 58XML Parsing 58SQLite Database 59Distributed Notifications 59

Core Service Frameworks 60Core Services Umbrella Framework 60Address Book 61Automator 61Core Data 61Foundation and Core Foundation 62Quick Look 64Store Kit 64WebKit 65Other Frameworks in the Core Services Layer 65

Core OS Layer 66High-Level Features 66

App Sandbox 66Code Signing 67

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

4

Contents

Page 5: OSX Technology Overview

Core OS Frameworks 67Accelerate 68Disk Arbitration 68OpenCL 68Open Directory (Directory Services) 69System Configuration Framework 69

Kernel and Device Drivers Layer 71High-Level Features 71

XPC Interprocess Communication and Services 71Caching API 72In-Kernel Video Capture 72

The Kernel 73Mach 7364-Bit Kernel 74Device-Driver Support 74Network Kernel Extensions 75

BSD 75IPC and Notification Mechanisms 76Network Support 77File-System Support 80Security 82Scripting Support 83Threading Support 83X11 84Software Development Support 84

Migrating from Cocoa Touch 88General Migration Notes 88

Migrating Your Data Model 88Migrating Your User Interface 89Migrating Your Controller Layer 90Application Types 91Migration Guidelines 91

Differences Between the UIKit and AppKit Frameworks 92User Events and Event Handling 92Windows 92Menus 93Documents 94Views and Controls 94

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

5

Contents

Page 6: OSX Technology Overview

File System 95Graphics, Drawing, and Printing 96Text 97Table Views 97Other Interface Differences 98

Foundation Framework Differences 100Differences in the Audio and Video Frameworks 101Differences in Other Frameworks Common to Both Platforms 102

Mac OS X Frameworks 104System Frameworks 104

Accelerate Framework 113Application Services Framework 114Automator Framework 114Carbon Framework 115Core Services Framework 116IMCore Framework 116Quartz Framework 117WebKit Framework 117

Xcode Frameworks 118System Libraries 118

Document Revision History 119

Glossary 121

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

6

Contents

Page 7: OSX Technology Overview

Figures and Tables

About the Technologies for Developing Mac OS X Software 8Figure I-1 Layers of Mac OS X 9

Software Product Types 13Table 1-1 Scripting language summary 22

Media Layer 35Table 3-1 Partial list of formats supported in Mac OS X 35Table 3-2 Features of the Mac OS X printing system 39Table 3-3 Quartz 2D technical specifications 42

Kernel and Device Drivers Layer 71Table 6-1 Network protocols 78Table 6-2 Network technology support 79Table 6-3 Supported local volume formats 81Table 6-4 Supported network file-sharing protocols 82

Migrating from Cocoa Touch 88Table 7-1 Comparison of graphics, drawing, and printing APIs 96Table 7-2 Differences between UIKit and AppKit in interface technologies 99Table 7-3 Foundation technologies available in Mac OS X but not in iOS 100Table 7-4 Differences in frameworks common to iOS and Mac OS X 102

Mac OS X Frameworks 104Table A-1 System frameworks 104Table A-2 Subframeworks of the Accelerate framework 113Table A-3 Subframeworks of the Application Services framework 114Table A-4 Subframeworks of the Automator framework 115Table A-5 Subframeworks of the Carbon framework 115Table A-6 Subframeworks of the Core Services framework 116Table A-7 Subframeworks of the IMCore framework 117Table A-8 Subframeworks of the Quartz framework 117Table A-9 Subframeworks of the WebKit framework 117Table A-10 Xcode frameworks 118

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

7

Page 8: OSX Technology Overview

Mac OS X is a modern operating system that combines a stable core with advanced technologies to help youdeliver world-class products. Knowing what these technologies are, and how to use them, can help streamlineyour own development process, while giving you access to key Mac OS X features.

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

8

About the Technologies for Developing Mac OS XSoftware

Page 9: OSX Technology Overview

This guide introduces you to the range of possibilities for developing software for Mac OS X, describes themany technologies you can use for software development, and points you to sources of information on thosetechnologies.

At a Glance

Mac OS X Has a Layered Architecture with Key Technologies in Each LayerYou can view the implementation of Mac OS X as a set of layers. At the lower layers of the system are thefundamental services on which all software relies. Subsequent layers contain more sophisticated services andtechnologies that build on (or complement) the layers below. Figure I-1 provides a graphical view of this layeredapproach.

Figure I-1 Layers of Mac OS X

The lower the layer a technology is in, the more specialized are the services it provides. Generally, technologiesin higher layers incorporate lower-level technologies to provide common app behaviors. When developing aCocoa app, you should always use the highest-level programming interface that meets the goals of your app.The layers (starting from the top) are:

● The Cocoa application layer incorporates technologies for building an app’s user interface, for respondingto user events, and for managing app behavior.

Note The term Cocoa in this book primarily refers to this layer of technology. In other Appletechnical documents, however, Cocoa frequently refers to all programmatic interfaces that youmight use to develop an app, regardless of system layer.

● The Media layer implements specialized technologies for playing, recording, and editing audiovisual mediaand for rendering and animating 2D and 3D graphics.

About the Technologies for Developing Mac OS X SoftwareAt a Glance

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

9

Page 10: OSX Technology Overview

● The Core Services layer contains several core services and technologies, including collection management,data formatting, memory management, string manipulation, process management, data-modelmanagement, XML parsing, stream-based I/O, low-level network communication, and many others.

● The Core OS layer defines programming interfaces that are related to hardware and networking. It providesservices for accessing information about network users and resources, for determining the reachability ofremote hosts, and for enabling access to devices and services on a network. It also publishes interfacesfor running high-performance computation tasks on a computer’s CPU and GPU.

● The Kernel and Device Drivers layer consists of the Mach kernel environment, device drivers, BSD libraryfunctions (libSystem), and other low-level components. The layer includes support for file systems,networking, security, interprocess communication, programming languages, device drivers, and extensionsto the kernel.

Relevant Chapters “Cocoa Application Layer” (page 25), “Media Layer” (page 35), “Core ServicesLayer” (page 51), “Core OS Layer” (page 66), “Kernel and Device Drivers Layer” (page 71)

You Can Create Many Different Kinds of Software for Mac OS XUsing the developer tools and system frameworks, you can create a wide variety of software for Mac OS X,including the following:

● Apps. There are two basic app variants: document-based apps and apps with a single main window. Toyour basic app, you can add other system technologies whose roles range from managing parts of yourapp to providing add-on features.

● Frameworks and libraries. You can make frameworks, dynamically shared libraries, and static libraries forcode sharing among apps.

● Command-line tools and daemons. In addition to utilities and other tools that you can run in a shell orfrom a shell script, you can build daemons and other background processes.

● App plug-ins and loadable bundles. You can create bundles containing code and resources that appscan dynamically load at runtime. In addition, you can create Automator actions and plug-ins for the AddressBook, Installer, and Interface Builder apps.

● System plug-ins. System plug-ins include Audio Units, kernel extensions, I/O Kit device drivers, preferencepanes, Spotlight importers, and screen savers.

About the Technologies for Developing Mac OS X SoftwareAt a Glance

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

10

Page 11: OSX Technology Overview

Relevant Chapter “Software Product Types” (page 13)

When Porting a Cocoa Touch App, Be Aware of the Similarities and Differencesin APIThe technology stacks on which Cocoa and Cocoa Touch apps are based have many similarities. Some systemframeworks are identical (or nearly identical) in each platform, including Foundation, Core Data, and AVFoundation. This commonality of API makes some migration tasks—for example, porting the data model ofyour Cocoa Touch app—easy.

Other migration tasks, however, involve more effort because of the differences not only in the set of systemframeworks but the differences between identically named frameworks. This is especially the case with theapplication frameworks, AppKit and UIKit. The differences between the view and controller classes offered bythese frameworks are considerable. Consequently, you need to reimplement the view and controller layers ofyour Cocoa Touch app.

Relevant Chapter “Migrating from Cocoa Touch” (page 88)

Tools to Help You Develop Software for Mac OS XApple provides a comprehensive suite of developer tools for creating Mac OS X software. The Xcode toolsinclude applications to help you design, create, debug, and optimize your software. At the heart of the toolsis Xcode, Apple’s integrated development environment. You use Xcode to organize and edit your source files,compile and debug your code, view documentation, and build all manner of software products. The tools suitealso includes compiler and performance tools, header files, sample code, and documentation for Appletechnologies. You can download the Xcode tools from the Member Center of the Apple Developer Connection(ADC) website (http://connect.apple.com/) or from the Developer Tools webpage (http://developer.ap-ple.com/technologies/tools/). Registration is required but free.

Note Xcode 4.0, introduced alongside Mac OS X v10.7, is a completely redesigned version of Xcodewith a tighter integration of the various developmental components. One of those components isInterface Builder, which previously was a separate application.

For an overview of the developer tools for Mac OS X, see the Developer Tools webpage (http://developer.ap-ple.com/technologies/tools/). To learn more about Xcode 4, read Xcode 4 User Guide .

About the Technologies for Developing Mac OS X SoftwareTools to Help You Develop Software for Mac OS X

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

11

Page 12: OSX Technology Overview

Information to Help You Develop Software for Mac OS XThe Mac OS X Developer Reference Library contains the documentation, sample code, tutorials, and otherinformation you need to write Mac OS X apps. The developer library contains thousands of pages ofdocumentation, ranging from getting started documents to API reference documents.

You can access the Mac OS X Developer Library from the Apple Developer website or from Xcode. In Xcode,choosing Developer Documentation from the Help menu displays the Xcode documentation viewer in theOrganizer window. This viewer is the central resource for accessing information about Mac OS X development.You can use the documentation viewer to browse the documentation, perform searches, and bookmarkdocuments you may want to refer to later.

At the top of the welcome page for the Mac OS X Developer Reference Library are links to Getting Started andRequired Reading documents. If you are new to software development for Mac OS X, browse through thesedocuments to familiarize yourself with the architectures, conventions, tools, and basic techniques for developingsoftware.

In addition the Mac OS Developer Library, there are other sources of information on developing different kindsof software for Mac OS X:

● Apple open source. Apple has released the source code for virtually all of the components of Darwin tothe developer community and continues to update the Darwin code base to include improvements aswell as security updates, bug fixes, and other important changes. (Darwin consists of the Mac OS X kernelenvironment, BSD libraries, and BSD command environment.)

Information about the Darwin open source efforts is available at http://developer.apple.com/darwin/ andat http://www.macosforge.org/.

● BSD. Berkeley Software Distribution (BSD) is an essential UNIX-based part of the operating system’s kernelenvironment. Several excellent books on BSD and UNIX are available in bookstores. But you can also findadditional information on any of the websites for BSD variants—for example, the FreeBSD project athttp://www.freebsd.org.

● Third-party books. Several excellent books on Mac OS X app development can be found online and inthe technical sections of book stores.

About the Technologies for Developing Mac OS X SoftwareInformation to Help You Develop Software for Mac OS X

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

12

Page 13: OSX Technology Overview

Apps are the most common type of software in Mac OS X. But there are many other types of software that youcan create. The following sections introduce the types of software you can create in Mac OS X and when youmight consider doing so.

AppsApps are by far the predominant type of software created for Mac OS X, or for any platform. You use Cocoa tobuild new apps for Mac OS X. See “Cocoa Application Layer” (page 25) for more information.

FrameworksA framework is a special type of bundle used to distribute shared resources, including library code, resourcefiles, header files, and reference documentation. Frameworks offer a more flexible way to distribute sharedcode that you might otherwise put into a dynamic shared library. Whereas image files and localized strings fora dynamic shared library would normally be installed in a separate location from the library itself, in a frameworkthey are integral to the framework bundle. Frameworks also have a version control mechanism that makes itpossible to distribute multiple versions of a framework in the same framework bundle.

Apple uses frameworks to distribute the public interfaces of Mac OS X, which are packaged in softwaredevelopment kits (SDK). (SDKs collect the frameworks, header files, tools, and other resources necessary fordeveloping software targeted at a specific version of a platform.) You can use frameworks to distribute publiccode and interfaces created by your company. You can also use frameworks to develop private shared librariesthat you can then embed in your apps.

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

13

Software Product Types

Page 14: OSX Technology Overview

Note Mac OS X also supports the concept of “umbrella” frameworks, which encapsulate multiplesubframeworks in a single package. However, this mechanism is used primarily for the distributionof Apple software. The creation of umbrella frameworks by third-party developers is notrecommended.

You can create your own frameworks using any programming language you choose; however, it is best tochoose a language that makes it easy to update the framework later. Apple frameworks generally exportprogrammatic interfaces in either ANSI C or Objective-C. Both of these languages have a well-defined exportstructure that makes it easy to maintain compatibility between different revisions of the framework. Althoughit is possible to use other languages when creating frameworks, you might run into binary compatibilityproblems later when you update your framework code.

For information on the structure and composition of frameworks, see Framework Programming Guide . Thatdocument also contains details on how to create public and private frameworks with Xcode.

Plug-insPlug-ins are the standard way to extend many apps and system behaviors. Plug-ins are bundles whose codeis loaded dynamically into the runtime of an app. Because they are loaded dynamically, they can be addedand removed by the user.

There are many opportunities for developing plug-ins for Mac OS X. Developers can create plug-ins for third-partyapps or for Mac OS X itself. Some parts of Mac OS X define plug-in interfaces for extending the basic systembehavior. The following sections list many of these opportunities for developers, although other software typesmay also use the plug-in model. (Pointers to relevant technical documents are given for each type of plug-in.)

Address Book Action Plug-InsAn Address Book action plug-in lets you populate the pop-up menus of the Address Book application withcustom menu items that use Address Book data to trigger a specific event. For example, you could add anaction to a phone number field to trigger the dialing of the number using a Bluetooth-enabled phone.

Address Book action plug-ins are best suited for developers who want to extend the behavior of the AddressBook application to support third-party hardware or software. For more information on creating an AddressBook action plug-in, see the documentation for the ABActionDelegate class.

For information on how to write an Address Book action plug-in, see Address Book Programming Guide for MacOS X .

Software Product TypesPlug-ins

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

14

Page 15: OSX Technology Overview

Application Plug-InsSeveral applications, including iTunes, Final Cut Pro, and Final Cut Express, use plug-ins to extend the featuresavailable from the application. You can create plug-ins to implement new effects for these applications or forother apps that support a plug-in model. For information about developing plug-ins for Apple applications,visit the ADC website at http://developer.apple.com/.

Automator Plug-InsAutomator is a workflow-based application that lets users assemble complex scripts graphically using a paletteof available actions. You can extend the default set of actions by creating Automator plug-ins to support newactions. Because they can be written in AppleScript or Objective-C, you can write plug-ins for your own app’sfeatures or for the features of other scriptable apps.

If you are developing an app, you should think about providing Automator plug-ins for your app’s most commontasks. AppleScript is one of the easiest ways for you to create Automator plug-ins because it can take advantageof existing code in your app. If you are an Objective-C developer, you can also use that language to createplug-ins.

For information on how to write an Automator plug-in, see Automator Programming Guide .

Contextual Menu Plug-InsThe Finder associates contextual menus with file-system items to give users a way to access frequently usedcommands quickly. Third-party developers can extend the list of commands found on these menus by definingtheir own contextual menu plug-ins. You might use this technique to make frequently used features availableto users without requiring them to launch your app. For example, an archiving program might providecommands to compress a file or directory.

The process for creating a contextual menu plug-in is similar to that for creating other types of plug-ins. Youstart by defining the code for registering and loading your plug-in, which might involve creating a factoryobject or explicitly specifying entry points. To implement the contextual menu behavior, you must thenimplement several callback functions defined by the Carbon Menu Manager for that purpose. Once complete,you install your plug-in in the Library/Contextual Menu Items directory at the appropriate level of thesystem, usually the local or user level.

For information on how to create a plug-in, see Plug-in Programming Topics . For information on the CarbonMenu Manager functions you need to implement, see Menu Manager Reference .

Software Product TypesPlug-ins

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

15

Page 16: OSX Technology Overview

Core Audio Plug-InsThe Core Audio system supports plug-ins for manipulating audio streams during most processing stages. Youcan use plug-ins to generate, process, receive, or otherwise manipulate an audio stream. You can also createplug-ins to interact with new types of audio-related hardware devices.

For an introduction to the Core Audio environment, download the Core Audio SDK from http://developer.ap-ple.com/sdk/ and read the documentation that comes with it. See also Core Audio Kit Framework Reference .

Image UnitsYou can create image units to use with the Core Image and Core Video technologies. An image unit is acollection of filters packaged together in a single bundle. Each filter implements a specific manipulation forimage data. For example, you could write a set of filters that perform different kinds of edge detection andpackage them as one image unit.

For more information about the Core Image framework, see Core Image Programming Guide .

Input Method ComponentsAn input method component is a code module that processes incoming data and returns an adjusted versionof that data. A common example of an input method is an interface for typing Japanese or Chinese charactersusing multiple keystrokes. The input method processes the user keystrokes and returns the complex characterthat was intended. Other examples of input methods include spelling checkers and pen-based gesturerecognition systems.

Input method components are implemented using the Carbon Component Manager. An input methodcomponent provides the connection between Mac OS X and any other programs your input method uses toprocess the input data. For example, you might use a background app to record the input keystrokes andcompute the list of potential complex characters that those keystrokes can create.

You can create input methods using the Input Method Kit (InputMethodKit.framework). For informationon how to use this framework, see Input Method Kit Framework Reference .

Metadata ImportersYou can create a metadata importer for your app’s file formats. Metadata importers are used by Spotlight togather information about the user’s files and build a systemwide index. This index is then used for advancedsearching based on more user-friendly information.

Software Product TypesPlug-ins

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

16

Page 17: OSX Technology Overview

If your app defines a custom file format, you should always provide a metadata importer for that file format.If your app relies on commonly used file formats, such as JPEG, RTF, or PDF, the system provides a metadataimporter for you.

For information on creating metadata importers, see Spotlight Importer Programming Guide .

Safari Plug-insSafari supports the Netscape-style plug-in model for incorporating additional types of content in the webbrowser. In Safari in Mac OS X v10.7 and later, these plug-ins run in their own process, which improves thestability and security of Safari. Netscape-style plug-ins include support for on-screen drawing, event handling,and networking and scripting functions.

Note Beginning in Mac OS X v10.7, Safari does not support WebKit plug-ins because they are notcompatible with the new process architecture. WebKit plug-ins are deprecated.

For information about creating Safari plug-ins with the Netscape API, see WebKit Plug-In Programming Topicsand WebKit Objective-C Framework Reference .

Safari ExtensionsWith Safari extensions you can add features both to the Safari web browser and to the content Safari displays.For example, you can add custom buttons to the browser’s toolbar, reformat webpages, block unwanted sites,and create contextual menu items. Extensions let you inject scripts and style sheets into pages of web content.

A Safari extension is a collection of HTML, JavaScript, and CSS files with support for both HTML5 and CSS3.Safari extensions are supported in Safari 5.0 web browsers running in both Mac OS X and Window systems.

To learn more about Safari extensions, read Safari ExtensionsDevelopmentGuide in the Safari Developer Library.

Dashboard WidgetsDashboard is****** a lightweight desktop layer for running widgets. Widgets are lightweight web apps thatdisplay information a user might use occasionally. You could write widgets to track stock quotes, view thecurrent time, or access key features of a frequently used app. Widgets reside in the Dashboard layer, which isactivated by the user and comes into the foreground in a manner similar to Exposé. Mac OS X comes withseveral standard widgets, including a calculator, clock, and iTunes controller.

Software Product TypesSafari Extensions

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

17

Page 18: OSX Technology Overview

Creating widgets is simpler than creating most apps because widgets are effectively HTML-based apps withoptional JavaScript code to provide dynamic behavior. Dashboard uses WebKit to provide the environmentfor displaying the HTML and running the JavaScript code. Your widgets can take advantage of several extensionsprovided by that environment, including a way to render content using Quartz-like JavaScript functions. Youcan create widgets using the Dashcode application.

For information on how to create widgets, see Dashboard Programming Topics .

Agent ApplicationsAn agent is a special type of application designed to help the user in an unobtrusive manner. Agents typicallyrun in the background, providing information as needed to the user or to another app. Agents can displaypanels occasionally or come to the foreground to interact with the user if necessary. User interactions shouldalways be brief and have a specific goal, such as setting preferences or requesting a piece of needed information.

An agent may be launched by the user but is more likely to be launched by the system or another app. As aresult, agents do not show up in the Dock or the window displayed by the Force Quit menu command. Agentsalso do not have a menu bar for choosing commands. User manipulation of an agent typically occurs throughdialogs or contextual menus in the agent user interface. For example, the iChat application uses an agent tocommunicate with the chat server and notify the user of incoming chat requests. The Dock is another agentprogram that is launched by the system for the benefit of the user.

The way to create an agent application is to create a bundled app and include the LSUIElement key in itsInfo.plist file. The LSUIElement key notifies the Dock that it should treat the app as an agent whendouble-clicked by the user. For more information on using this key, see Runtime Configuration Guidelines .

Screen SaversScreen savers are small programs that take over the screen after a certain period of idle activity. Screen saversprovide entertainment and also prevent the screen image from being burned into the surface of a screenpermanently. Mac OS X supports both slideshows and programmatically generated screen-saver content.

SlideshowsA slideshow is a simple type of screen saver that does not require any code to implement. To create a slideshow,you create a bundle with an extension of .slideSaver. Inside this bundle, you place a Resources directorycontaining the images you want to display in your slideshow. Your bundle should also include an informationproperty list that specifies basic information about the bundle, such as its name, identifier string, and version.

Software Product TypesAgent Applications

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

18

Page 19: OSX Technology Overview

Mac OS X includes several slideshow screen savers you can use as templates for creating your own. Thesescreen savers are located in /System/Library/Screen Savers. You should put your own slideshows ineither /Library/Screen Savers or in the ~/Library/Screen Savers directory of a user.

Programmatic Screen SaversA programmatic screen saver is one that continuously generates content to appear on the screen. You can usethis type of screen saver to create animations or to create a screen saver with user-configurable options. Thebundle for a programmatic screen saver ends with the .saver extension.

You create programmatic screen savers using Cocoa and the Objective-C language. Specifically, you create acustom subclass of ScreenSaverView that provides the interface for displaying the screen saver content andoptions. The information property list of your bundle provides the system with the name of your customsubclass.

For information on creating programmatic screen savers, see Screen Saver Framework Reference .

ServicesServices are not separate programs that you write; instead, they are features exported by your app for thebenefit of other apps. Services let you share the resources and capabilities of your app with other apps in thesystem.

Services typically act on the currently selected data. Upon initiation of a service, the app that holds the selecteddata places it on the pasteboard. The app whose service was selected then takes the data, processes it, andputs the results (if any) back on the pasteboard for the original app to retrieve. For example, a user might selecta folder in the Finder and choose a service that compresses the folder contents and replaces them with thecompressed version. Services can represent one-way actions as well. For example, a service could take thecurrently selected text in a window and use it to create the content of a new email message.

For information on how to implement services in your Cocoa app, see Services Implementation Guide .

Preference PanesPreference panes are used primarily to modify system preferences for the current user. Preference panes areimplemented as plug-ins and installed in /Library/PreferencePanes on the user’s system. App developerscan also take advantage of these plug-ins to manage per-user app preferences; however, most apps managepreferences using the code provided by the application environment.

You might need to create preference panes if you create:

Software Product TypesServices

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

19

Page 20: OSX Technology Overview

● Hardware devices that are user-configurable

● Systemwide utilities, such as virus protection programs, that require user configuration

If you are an app developer, you might want to reuse preference panes intended for the System Preferencesapplication or use the same model to implement your app preferences.

Because the programmatic interfaces are based on Objective-C, you write preference panes primarily usingCocoa. For more information, see Preference Pane Programming Guide .

Web ContentMac OS X supports a variety of techniques and technologies for creating web content. Dynamic websites andweb services offer web developers a way to deliver their content quickly and easily.

In addition to “Identity Services” (page 58) and “Dashboard Widgets” (page 17), the following sections listways to deliver web content in Mac OS X. For more information about developing web content, see GettingStarted with Internet and Web .

Dynamic WebsitesMac OS X provides support for creating and testing dynamic content in web pages. If you are developingCGI-based web apps, you can create websites using a variety of scripting technologies, including Perl and thePHP Hypertext Preprocessor. A complete list of scripting technologies is provided in “Scripts” (page 22). Youcan also create and deploy more complex web apps using JBoss, Tomcat, and WebObjects. To deploy yourwebpages, use the built-in Apache web server.

Safari, Apple’s web browser, provides standards-compliant support for viewing pages that incorporate numeroustechnologies, including HTML, XML, XHTML, DOM, CSS, Java, and JavaScript. You can also use Safari to testpages that contain multimedia content created for QuickTime, Flash, and Shockwave.

SOAP, XML-RPC, and Web ServicesThe Simple Object Access Protocol (SOAP) is an object-oriented protocol that defines a way for programs tocommunicate over a network. XML-RPC is a protocol for performing remote procedure calls between programs.In Mac OS X, you can create clients that use these protocols to gather information from web services acrossthe Internet. To create these clients, you use technologies such as PHP, JavaScript, AppleScript, and Cocoa.

If you want to provide your own web services in Mac OS X, you can use WebObjects or implement the serviceusing the scripting language of your choice. You then post your script code to a web server, give clients a URL,and publish the message format your script supports.

Software Product TypesWeb Content

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

20

Page 21: OSX Technology Overview

For information on how to create client programs using AppleScript, see XML-RPC and SOAP ProgrammingGuide . For information on how to create web services, see WebObjects Web Services Programming Guide .

Mail StationeryThe Mail application supports the creation of email messages using templates. Templates provide the userwith prebuilt email messages that can be customized quickly before being sent. Because templates areHTML-based, they can incorporate images and advanced formatting to give the user’s email a much morestylish and sophisticated appearance.

Developers and web designers can create custom template packages for external or internal users. Eachtemplate consists of an HTML page, property list file, and images packaged together in a bundle, which is thenstored in the Mail application’s stationery directory. The HTML page and images define the content of theemail message and can include drop zones for custom user content. The property list file provides Mail withinformation about the template, such as its name, ID, and the name of its thumbnail image.

For information about how to create new stationery templates, see Mail Programming Topics .

Command-Line ToolsCommand-line tools are simple programs that manipulate data using a text-based interface. These tools donot use windows, menus, or other user interface elements traditionally associated with apps. Instead, they runfrom the command-line environment of the Terminal application. Command-line tools require less explicitknowledge of the system to develop and because of that are often simpler to write than many other types ofapps. However, command-line tools usually serve a more technically savvy crowd who are familiar with theconventions and syntax of the command-line interface.

Xcode supports the creation of command-line tools from several initial code bases. For example, you can createa simple and portable tool using standard C or C++ library calls, or a tool more specific to Mac OS X usingframeworks such as Core Foundation, Core Services, or Cocoa Foundation.

Launch Items and DaemonsLaunch items are special programs that launch other programs or perform one-time operations during startupand login periods. Daemons are programs that run continuously and act as servers for processing client requests.You typically use launch items to launch daemons or perform periodic maintenance tasks, such as checkingthe hard drive for corrupted information.

Software Product TypesMail Stationery

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

21

Page 22: OSX Technology Overview

Launch items should not be confused with the login items found in the Accounts system preferences. Loginitems are typically agent applications that run within a given user’s session and can be configured by that user.Launch items are not user-configurable.

Few developers should ever need to create launch items or daemons. They are reserved for the special casewhere you need to guarantee the availability of a particular service. For example, Mac OS X provides a launchitem to run the DNS daemon. Similarly, a virus-detection program might install a launch item to launch adaemon that monitors the system for virus-like activity. In both cases, the launch item would run its daemonin the root session, which provides services to all users of the system.

For more information about launch items and daemons, see Daemons and Services Programming Guide .

ScriptsA script is a set of text commands that are interpreted at runtime and turned into a sequence of actions. Mostscripting languages provide high-level features that make it easy to implement complex workflows very quickly.Scripting languages are often very flexible, letting you call other programs and manipulate the data they return.Some scripting languages are also portable across platforms, so that you can use your scripts anywhere.

Table 1-1 lists many of the scripting languages supported by Mac OS X along with a description of the strengthsof each language.

Table 1-1 Scripting language summary

DescriptionLanguage

An English-based language for controlling scriptable apps in Mac OS X. Use it to tietogether apps involved in a custom workflow or repetitive job. SeeAppleScript Overviewfor more information.

AppleScript

A Bourne-compatible shell script language used to build programs on UNIX-basedsystems.

bash

The C shell script language used to build programs on UNIX-based systems.csh

A general-purpose scripting language supported on many platforms. It comes with anextensive set of features suited for text parsing and pattern matching and also has someobject-oriented features. See http://www.perl.org/ for more information.

Perl

A cross-platform, general-purpose scripting language that is especially suited for webdevelopment. See http://www.php.net/ for more information.

PHP

Software Product TypesScripts

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

22

Page 23: OSX Technology Overview

DescriptionLanguage

A general-purpose, object-oriented scripting language implemented for many platforms.See http://www.python.org/ for more information. You can also use Python with theCocoa scripting bridge; see Ruby and Python Programming Topics for Mac .

Python

A general-purpose, object-oriented scripting language implemented for many platforms.See http://www.ruby-lang.org/ for more information. You can also use Ruby with theCocoa scripting bridge; see Ruby and Python Programming Topics for Mac .

Ruby

The Bourne shell script language used to build programs on UNIX-based systems.sh

Tool Command Language. A general-purpose language implemented for many platforms.It is often used to create graphical interfaces for scripts. See http://www.tcl.tk/ for moreinformation.

Tcl

A variant of the C shell script language used to build programs on UNIX-based systems.tcsh

The Z shell script language used to build programs on UNIX-based systems.zsh

Scripting Additions for AppleScriptA scripting addition is a way to deliver additional functionality for AppleScript scripts. It extends the basicAppleScript command set by adding systemwide support for new commands or data types. Developers whoneed features not available in the current command set can use scripting additions to implement those featuresand make them available to all programs. For example, one of the built-in scripting additions extends the basicfile-handling commands to support the reading and writing of file contents from an AppleScript script.

For information on how to create a scripting addition, see Technical Note TN1164, “Scripting Additions for MacOS X.”

Kernel ExtensionsMost developers have little need to create kernel extensions. Kernel extensions are code modules that loaddirectly into the kernel process space and therefore bypass the protections offered by the Mac OS X coreenvironment. The situations in which you might need a kernel extension are the following:

● Your code needs to handle a primary hardware interrupt.

● The client of your code is inside the kernel.

● A large number of apps require a resource your code provides. For example, you might implement afile-system stack using a kernel extension.

Software Product TypesScripting Additions for AppleScript

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

23

Page 24: OSX Technology Overview

● Your code has special requirements or needs to access kernel interfaces that are not available in the userspace.

Although device drivers are a type of kernel extension, by convention the term “kernel extension” refers tocode modules typically used to implement new network stacks or file systems. You would not use kernelextensions to communicate with external devices such as digital cameras or printers. (For information oncommunicating with external devices, see “Device Drivers” (page 24).)

Note Kernel data structures have an access model that makes it possible to write nonfragile kernelextensions—that is, kernel extensions that do not break when the kernel data structures change.Developers are highly encouraged to use the kernel-extension API for accessing kernel data structures.

For information about writing kernel extensions, see Kernel Programming Guide .

Device DriversDevice drivers are a special type of kernel extension that enable Mac OS X to communicate with many hardwaredevices, including mice, keyboards, and FireWire drives. Device drivers communicate hardware status to thesystem and facilitate the transfer of device-specific data to and from the hardware. Mac OS X provides defaultdrivers for many types of devices, but these might not meet the needs of all developers.

Although developers of mice and keyboards may be able to use the standard drivers, many other developersrequire custom drivers. Developers of hardware such as scanners, printers, AGP cards, and PCI cards typicallyhave to create custom drivers for their devices. These devices require more sophisticated data handling thanis usually needed for mouse devices and keyboards. Hardware developers also tend to differentiate theirhardware by adding custom features and behavior, which makes it difficult for Apple to provide generic driversto handle all devices.

Apple provides code you can use as the basis for your custom drivers. The I/O Kit provides an object-orientedframework for developing device drivers using C++. For information on developing device drivers, see I/O KitFundamentals .

Software Product TypesDevice Drivers

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

24

Page 25: OSX Technology Overview

The technologies and applications that are part of Cocoa, the application layer of Mac OS X, are essential tothe compelling user experience that defines the Macintosh. The Cocoa layer is primarily responsible for theappearance of apps and their responsiveness to user actions. To contribute to the user experience, your appshould support the features that help it blend into the Mac OS X ecosystem and create a seamless userexperience.

Aqua is sometimes the name given the appearance and overall behavior of Mac OS X apps. These apps exhibitconsistent behaviors and incorporate color, depth, translucence, and complex textures into a visually appealinginterface. If you create your app using the interfaces of the Cocoa application layer, the app gets much of theAqua appearance automatically. However, you should still ensure that your app’s appearance and behaviorconform to the user-experience guidelines stipulated by Apple for apps. Read OS X Human Interface Guidelinesto gain invaluable insights on creating Aqua-compliant apps and on the best Mac OS X interface technologiesto use.

High-Level FeaturesThe Cocoa layer implements many features that are distinctive aspects of the user experience in Mac OS X.The following sections describe some of the more important features.

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

25

Cocoa Application Layer

Page 26: OSX Technology Overview

ResumeResume is a system-wide enhancement of the user experience, introduced in Mac OS X v10.7, that supportsapp persistence. A user can log out or shut down the operating system, and on next login or startup, Mac OSX automatically relaunches the apps that were last running and restores the windows that were last opened.If your app provides the necessary support, reopened windows have the same size and location as before; inaddition, window contents are scrolled to the previous position and selections are restored.

App persistence requires you to implement the ancillary programmatic features of automatic and sudden apptermination, user interface preservation, and Auto Save, which the following sections describe.

Automatic and Sudden Termination of AppsAutomatic app termination, a feature introduced in Mac OS X v10.7, manages the life cycle of apps behind thescenes, terminating apps that are not being used and thereby reclaiming resources such as memory. With thisfeature, users no longer need to explicitly quit apps (although they still can, if they want to). Instead, theoperating system is responsible for managing app processes with the goal of ensuring optimal systemperformance.

For your apps to participate in automatic termination, you must opt-in to the feature and implement therequired methods for user interface preservation and (if your app is document-based) automatic documentsaving. If your app is not document-based, your app should still save its data at appropriate intervals.

Note that automatic termination is distinct from the related feature of sudden termination, in which theoperating system immediately kills app processes when users log out, shut down the system, or perform similaroperations. Apps should implement both automatic termination and sudden termination.

To learn more about automatic app termination, see “Automatic and Sudden Termination of Applications Improve

the User Experience” in Mac App Programming Guide .

User Interface PreservationUser interface preservation is a programmatic feature introduced in Mac OS X v10.7 that saves the state ofyour app’s windows and restores the windows to that state during subsequent launches of your app. Restoredwindows have the size and location on the screen as they had previously, are scrolled to the previous position,and have the previously selected item as the selection. If your app supports automatic app termination, it isimportant that it also support user interface preservation. If you do not preserve the state of your app’s userinterface, then the app launches in its default state.

Although the AppKit framework handles the writing of your app’s state to disk, your app must tell it what tosave. AppKit saves data not just for windows marked for preservation, but for all objects in the window’s viewhierarchy as well as associated window controllers and document objects. When the app is next launched and

Cocoa Application LayerHigh-Level Features

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

26

Page 27: OSX Technology Overview

AppKit finds preserved interface data, the framework communicates the data to a specially designated restorationclass whose role is to re-create a window and all of the critical objects required by the window. For moreinformation about user interface preservation, see “User Interface Preservation” in Mac App Programming Guide .

Auto SaveStarting in Mac OS X v10.7, apps can (with the help of the operating system) automatically save their documentsat frequent intervals. The system writes document data to disk as necessary so that data displayed in a documentwindow is, in effect, always the same as the document data on disk. With the Auto Save feature, users no longerhave to explicitly save documents and no longer have to worry about losing unsaved changes. Apps providedby Apple have been implemented to automatically save their documents.

If your app is document-based, you can acquire this automatic saving behavior by overriding methods ofNSDocument. For details about implementing automatic document saving (or Auto Save), see “Automatic

Document Saving” in Mac App Programming Guide . If your app is not document-based, you should still saveapp data at key app life-cycle junctures and whenever data is entered or changed.

A side benefit of automatic document saving is automatic document versioning—the Versions feature. Bychoosing a command from a pull-down menu at the upper-right corner of the document window, a user canview a list of previous versions of the document that were created as the user was editing it (similar to the listthat Time Machine provides). Although users cannot change a previous version of the document, they canview it, copy and paste portions of it, and change viewing options. Although users can undo some editingactions (and thus return to previous document versions), you can mark some undo actions as discardable ifthe document is locked in some way (for example, if the version is on a locked volume).

Full-Screen ModeStarting in Mac OS X v10.7, you can enable full-screen mode for your app by calling a single method. Enablingfull-screen mode adds an Enter Full Screen menu item to the View menu or, if there is no View menu, to theWindow menu. When a user chooses this menu item, the frontmost app or document window fills the entirescreen.

The AppKit framework provides support for customizing the appearance and behavior of full-screen windows.For example, you can set a window-style mask and can implement custom animations when an app entersand exits full-screen mode.

You enable and manage full-screen support through methods of the NSApplication and NSWindow classesand the NSWindowDelegate Protocol. To find out more about this feature, read “Implementing the Full-Screen

Experience” in Mac App Programming Guide .

Cocoa Application LayerHigh-Level Features

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

27

Page 28: OSX Technology Overview

Cocoa Auto LayoutCocoa Auto Layout, a feature introduced in Mac OS X v10.7, improves upon the “springs and struts” modelpreviously used to lay out the elements of a user interface. Auto Layout is a rule-based system designed toimplement the layout guidelines described in OS X Human Interface Guidelines . It expresses a larger class ofrelationships and is more intuitive to use than springs and struts.

The entities used in Auto Layout are Objective-C objects called constraints . This approach brings you a numberof benefits:

● Localization through swapping of strings alone, instead of also revamping layouts

● Mirroring of user-interface elements for right-to-left languages like Hebrew and Arabic

● Better layering of responsibility between objects in the view and controller layers

A view object usually knows best about its standard size and its positioning within its superview andrelative to its sibling views. A controller can override these values if something nonstandard is required.

You define constraints through a simple language for visualizing layout of UI elements. The attributes youemploy are in terms of leading, trailing, left, right, top, bottom, width, and height. (Leading and trailing aresimilar to left and right, but more expressive because they automatically mirror the constraint in a right-to-leftenvironment like Hebrew or Arabic.)

A constraint object has an assigned priority level; a constraint with a higher priority is satisfied before a constraintwith a lower priority.

You create a constraint object using the NSLayoutConstraint class. By calling methods of the NSView class,you assign the object to a common ancestor of the views to which the constraint applies. You can overridemethods of the NSWindow and NSView classes to update view constraints before updating their layout anddisplay.

For more information on Auto Layout, see Cocoa Auto Layout Guide .

PopoversStarting in Mac OS X v10.7, AppKit provides support for popovers by way of the NSPopover class. A popoverprovides a means to display additional content related to existing content on the screen. The view containingthe existing content—from which the popover arises—is referred to in this context as a positioning view . Youuse an anchor to express the relation between a popover and its positioning view.

You configure a popover in terms of appearance and behavior. One important part of this is to specify whichuser interactions cause the popover to close.

Cocoa Application LayerHigh-Level Features

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

28

Page 29: OSX Technology Overview

AppKit automatically positions a popover relative to its positioning view and moves the popover when itspositioning view moves. You can fine-tune the relative position of a popover by specifying a positioningrectangle within the positioning view.

By implementing the appropriate delegate method, you can configure a popover to detach itself and becomea separate window when a user drags it.

For more information, seeNSPopoverClass Reference andNSPopoverDelegateProtocol Reference . For guidelineson using popovers, see “Popovers” in OS X Human Interface Guidelines .

Software ConfigurationMac OS X programs commonly use property list files (also known as plist files) to store configuration data. Aproperty list is a text or binary file used to manage a dictionary of key-value pairs. Apps use a special type ofproperty list file, called an information property list (Info.plist) file, to communicate key attributes of theapp—such as the app’s name, unique identification string, and version information—to the system. Apps alsouse property list files to store user preferences or other custom configuration data. If your app stores customconfiguration data, you should consider using property list files as well.

The advantage of property list files is that they are easy to edit and modify from outside the runtime environmentof your app. Mac OS X provides several tools for creating and modifying property list files. The Property ListEditor application that comes with Xcode is the main application for editing the contents of property lists.Xcode also provides a custom interface for editing your app’s Info.plist file. (For information aboutinformation property list files and the keys you put in them, see Runtime Configuration Guidelines andInformation Property List Key Reference .)

Inside your program, you can read and write property list files programmatically using facilities found in bothCore Foundation and Cocoa. For more information on creating and using property lists programmatically, seeProperty List Programming Guide or Property List Programming Topics for Core Foundation .

AccessibilityMillions of people have some type of disability or special need. Federal regulations in the United States stipulatethat computers used in government or educational settings must provide reasonable access for people withdisabilities. Mac OS X includes built-in functionality to accommodate users with special needs. It also providessoftware developers with the functions they need to support accessibility in their own apps.

Apps that use Cocoa interfaces receive significant support for accessibility automatically. For example, appsget the following support for free:

● Zoom features let users increase the size of onscreen elements.

● Sticky keys let users press keys sequentially instead of simultaneously for keyboard shortcuts.

Cocoa Application LayerHigh-Level Features

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

29

Page 30: OSX Technology Overview

● Mouse keys let users control the mouse with the numeric keypad.

● Full keyboard access mode lets users complete any action using the keyboard instead of the mouse.

● Speech recognition lets users speak commands rather than type them.

● Text-to-speech reads text to users with visual disabilities.

● VoiceOver provides spoken user interface features to assist visually impaired users.

If your app is designed to work with assistive devices (such as screen readers ), you may need to provideadditional support. Both Cocoa and Carbon integrate support for accessibility protocols in their frameworks;however, there may still be times when you need to provide additional descriptions or want to changedescriptions associated with your windows and controls. In those situations, you can use the appropriateaccessibility interfaces to change the settings.

For more information about accessibility, see Accessibility Overview .

AppleScriptMac OS X employs AppleScript as the primary language for making apps scriptable. With AppleScript, userscan write scripts that link together the services of multiple scriptable apps.

When designing new apps, you should consider AppleScript support early in the process. The key to a gooddesign that supports AppleScript is choosing an appropriate data model for your app. The design must notonly serve the purposes of your app but should also make it easy for AppleScript implementers to manipulateyour content. Once you settle on a data model, you can implement the Apple event code needed to supportscripting.

For information about AppleScript in Mac OS X, go to http://www.macosxautomation.com/applescript/. Fordeveloper documentation explaining how to support AppleScript in your programs, see Applescript Overview.

SpotlightSpotlight provides advanced search capabilities for apps. The Spotlight server gathers metadata from documentsand other relevant user files and incorporates that metadata into a searchable index. The Finder uses thismetadata to provide users with more relevant information about their files. For example, in addition to listingthe name of a JPEG file, the Finder can also list its width and height in pixels.

App developers use Spotlight in two different ways. First, you can search for file attributes and content usingthe Spotlight search API. Second, if your app defines its own custom file formats, you should incorporate anyappropriate metadata information in those formats and provide a Spotlight importer plug-in to return thatmetadata to Spotlight.

Cocoa Application LayerHigh-Level Features

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

30

Page 31: OSX Technology Overview

Note You should not use Spotlight for indexing and searching the general content of a file. Spotlightis intended for searching only the meta information associated with files. To search the actual contentsof a file, use the Search Kit API. For more information on Search Kit, see “Other Frameworks in theCore Services Layer” (page 65).

For more information on using Spotlight in your apps, see Spotlight Overview .

Ink ServicesThe Ink Services feature of Mac OS X provides handwriting recognition for apps that support the Cocoa textsystem (although the automatic support provided by this text system is limited to basic recognition). The Inkframework offers several features that you can incorporate into your apps, including the following:

● Enabling or disabling handwriting recognition programmatically

● Accessing Ink data directly

● Supporting either deferred recognition or recognition on demand

● Supporting the direct manipulation of text by means of gestures

The Ink Services feature is implemented by the Ink framework (Ink.framework). The Ink framework is notintended solely for developers of end-user apps. Hardware developers can also use it to implement a handwritingrecognition solution for a new input device. You might also use the Ink framework to implement your owncorrection model to provide users with a list of alternate interpretations for handwriting data.

The Ink framework is a subframework of Carbon.framework; you should link directly with the umbrellaframework and not Ink.framework. For more information on using Ink Services in Cocoa apps, see Using InkServices in Your Application .

FrameworksThe Cocoa layer includes the frameworks described in the following sections.

Cocoa Umbrella FrameworkThe Cocoa umbrella framework (Cocoa.framework) imports the core Objective-C frameworks for appdevelopment: AppKit, Foundation, and Core Data.

● AppKit (AppKit.framework). This is the only framework of the three that is actually in the the Cocoalayer. See “AppKit” (page 32) for a summary of AppKit features and classes.

Cocoa Application LayerFrameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

31

Page 32: OSX Technology Overview

● Foundation (Foundation.framework). The classes of the Foundation framework (which resides in theCore Services layer) implement data management, file access, process notification, memory management,network communication, and other low-level features. AppKit has a direct dependency on Foundationbecause many of its methods and functions take as parameters, or return as values, instances of Foundationclasses.

To find out more about Foundation, see “Foundation and Core Foundation” (page 62).

● Core Data (CoreData.framework). The classes of the Core Data framework (which also resides in theCore 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 datasets.

For more information about Core Data, see “Core Data” (page 61).

AppKitAppKit is the key framework for Cocoa apps. The classes in the AppKit framework implement the user interfaceof an app, including windows, dialogs, controls, menus, and event handling. They also handle much of thebehavior required of a well-behaved app, including menu management, window management, documentmanagement, Open and Save dialogs, and pasteboard (clipboard) behavior.

In addition to classes for windows, menus, event handling, and a wide variety of views and controls, AppKithas window- and data-controller classes and classes for fonts, colors, images, and graphics operations. A largesubset of classes comprise the Cocoa text system, described in “Text, Typography, and Fonts” (page 37). OtherAppKit classes support document management, printing, and services such as spellchecking, help, speech,and pasteboard and drag-and-drop operations.

Apps can participate in many of the features that make the user experience of Mac OS X such an intuitive,productive, and rewarding experience. These features include the following:

● Spaces. Spaces lets the user organize windows into groups and switch back and forth between groupsto avoid cluttering up the desktop. AppKit provides support for sharing windows across spaces throughthe use of collection behavior attributes on the window. For information about setting these attributes,see NSWindow Class Reference .

● Help Support. Apps can provide users with immediate and in-depth answers to questions by implementinghelp tags (also called tooltips) and documentation. In addition, the Spotlight for Help feature makes iteasier for users to locate items in complex menu. For information on adding help to a Cocoa app, seeOnline Help .

Cocoa Application LayerFrameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

32

Page 33: OSX Technology Overview

● Fast User Switching. With this feature, multiple users can share access to a single computer withoutlogging out. One user’s session can continue to run while another user logs in and accesses the computer.Fast user switching, however, means that an app should avoid doing anything that might affect anotherversion of the app running in a different session. Multiple User Environment Programming Topics explainshow to implement this behavior.

Interface Builder (integrated into Xcode 4) includes many objects of the AppKit framework in its library. Thismakes it possible for you to create most of your user interface (including much of its behavior) graphicallyrather than programatically. With the addition of Cocoa bindings and Core Data, you can also implement mostof the rest of your app graphically as well.

For an overview of the AppKit framework, see the introduction to the Application Kit Framework Reference .Mac App Programming Guide offers a practical discussion of how you use AppKit classes (mostly) to implementan app’s user interface, its documents, and its overall behavior.

Preference PaneThe Preference Pane framework (PreferencePane.framework) lets you create plug-ins containing a userinterface for setting app preferences. At runtime, the System Preferences application (or the app itself ) candynamically load the plug-in and present the settings interface to users. In System Preferences, each icon inits Show All view represents an individual preference pane plug-in. You typically implement Preference Paneplug-ins when your app lacks its own user interface or has a very limited user interface but needs to beconfigurable. You must not only create the plug-in but the application code that reads and writes the preferencesettings.

For more information about creating preference-pane plug-ins, see Preference Pane Programming Guide .

Screen SaverThe Screen Saver framework (ScreenSaver.framework) contains classes for creating dynamically loadablebundles implementing screen savers that users can select in the Desktop & Screen Saver pane of the SystemPreferences application. The classes help to implement the screen saver view and preview and manage screensaver preferences. Functions provide information often needed by screen savers such as random values.

To learn more about creating screen savers, see Screen Saver Framework Reference . Also read the technicalnote Building Screen Savers for Snow Leopard for additional information.

Cocoa Application LayerFrameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

33

Page 34: OSX Technology Overview

Security InterfaceThe Security Interface framework (SecurityInterface.framework) contains classes that provideuser-interface elements for programs implementing security features such as authorization, access to digitalcertificates, and access to items in keychains. There are classes for creating custom views and standard securitycontrols, 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 .

Cocoa Application LayerFrameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

34

Page 35: OSX Technology Overview

The graphics and multimedia capabilities of Mac OS X set it apart from other operating systems. The coregraphics technology enables advanced compositing operations with support for hardware-based renderingon supported graphics hardware. On top of this core technology are an array of other technologies that makeit possible to draw 2D, 3D, and video-based content. The system also provides advanced audio systems forthe generation, playback, and manipulation of multichannel audio.

Supported Media FormatsMac OS X supports more than a hundred media types, covering a range of audio, video, image, and streamingformats. Table 3-1 lists some of the more common supported file formats.

Table 3-1 Partial list of formats supported in Mac OS X

PICT, BMP, GIF, JPEG, TIFF, PNG, DIB, ICO, EPS, PDFImage formats

AAC, AIFF, WAVE, uLaw, AC3, MPEG-3, MPEG-4 (.mp4, .m4a), .snd,.au, .caf, Adaptive multi-rate (.amr)

Audio file and data formats

AVI, AVR, DV, M-JPEG, MPEG-1, MPEG-2, MPEG-4, AAC, OpenDML, 3GPP,3GPP2, AMC, H.264, iTunes (.m4v), QuickTime (.mov, .qt)

Video file formats

HTTP, RTP, RTSPWeb streaming protocols

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

35

Media Layer

Page 36: OSX Technology Overview

Graphics TechnologiesA distinctive quality of any Mac OS X application is high-quality graphics in its user interface. The simplest,most efficient, and most common way to ensure high-quality graphics when creating an application is to usethe standard views and controls of the AppKit framework along with prerendered images. At runtime, let thesystem do the work of rendering the application’s user interface. There can be situations, however, when youneed to go beyond off-the-shelf views and simple graphics.

The following sections describe some of the graphics technologies of Mac OS X. For summaries of alltechnologies, see “Media Layer Frameworks” (page 41).

Graphics and DrawingMac OS X offers the following system technologies for graphics and drawing.

Cocoa DrawingThe AppKit framework provides object-oriented wrappers for many of the features found in Quartz 2D. Cocoaprovides support for drawing primitive shapes such as lines, rectangles, ovals, arcs, and Bezier paths. It supportsdrawing in both standard and custom color spaces and it supports content manipulations using graphicstransforms. Because it is built on top of Quartz 2D, drawing calls made from Cocoa are composited along withall other Quartz 2D content. You can even mix Quartz 2D drawing calls (and drawing calls from other systemgraphics technologies) with Cocoa calls in your code.

The AppKit framework is described in “AppKit” (page 32). For more information on how to draw using Cocoa,see Cocoa Drawing Guide .

Other Frameworks for Graphics and DrawingOther than AppKit, the three most important frameworks for graphics and drawing in Mac OS X are AppKit(specifically, its Cocoa drawing interface), Quartz 2D client, Core Animation, and OpenGL.

● Core Graphics (also known as Quartz 2D) offers native 2D vector- and image-based rendering capabilitiesthat are resolution- and device-independent. These capabilities include path-based drawing, painting withtransparency, shading, drawing of shadows, transparency layers, color management, anti-aliased rendering,and PDF document generation. The Core Graphics framework is in the Application Services umbrellaframework.

Quartz is at the heart of the Mac OS X graphics and windowing environment. It provides rendering supportfor 2D content and combines a rich imaging model with on-the-fly rendering, compositing, and anti-aliasingof content. It also implements the windowing system for Mac OS X and provides low-level services suchas event routing and cursor management. (See “Core Graphics” (page 41) for more information.)

Media LayerGraphics Technologies

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

36

Page 37: OSX Technology Overview

● Core Animation enables your application to create fluid animations using advanced compositing effects.It defines a hierarchical view-like abstraction that mirrors a hierarchy of views and is used to performcomplex animations of user interfaces. Core Animation is implemented by the Quartz Core framework(QuartzCore.framework).

● OpenGL is an open, industry-standard technology for creating and animating real-time 2D and 3D graphics.It is primarily intended for games and other applications with real-time rendering capabilities.

For more information on these frameworks, see the corresponding entry in “Media Layer Frameworks” (page41).

Text, Typography, and FontsMac OS X provides extensive support for advanced typography for Cocoa applications. With this support, yourapplication can control the fonts, layout, typesetting, text input, and text storage when managing the displayand editing of text. For the most basic text requirements, you can use the text fields, text views, and othertext-displaying objects provided by the AppKit framework.

Beyond that, you have two technologies to draw upon for your application’s text, font, and typography needs:the Cocoa text system and the Core Text. Unless you need low-level access to the layout manager routines,the Cocoa text system should provide most of the features and performance you need. If you need a lower-levelAPI for drawing any kind of text into a CGContext, then you should consider using the Core Text API.

● The Cocoa text system. A collection of AppKit classes that together provide a complete set of high-qualitytypographical services. With these services, applications can create, edit, display, and store text with allthe characteristics of fine typesetting, such as kerning, ligatures, line-breaking, and justification. You canuse the Cocoa Text system to display small or large amounts of text and can customize the default layoutmanager classes to support custom layout. The Cocoa text system is the recommended technology formost applications that require text handling and typesetting capabilities.

AppKit also offers a class (NSFont), a font manager, and a font panel. In Mac OS X v10.7, the Cocoa textsystem adds support for vertical text and linguistic tagging.

For an overview of the Cocoa text system, see Text System Storage Layer Overview .

● Core Text.A framework with low-level interfaces for laying out Unicode text and handling Unicode fonts.Core Text provides the underlying implementation for many features of the Cocoa text system.

To learn more about the Core Text framework, see “Core Text” (page 42).

Media LayerGraphics Technologies

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

37

Page 38: OSX Technology Overview

ImagesBoth AppKit and Quartz let you create objects representing images (NSImage and CGImageRef) from varioussources, draw these images to an appropriate graphics context, and even composite one image over anotheraccording to a given blending mode. Beyond the native capabilities of AppKit and Core Graphics, you can doother things with images using the following frameworks:

● Image Kit. A framework allows users of your application to browse, view, edit, and process images. It alsolets users browse and select Core Image filters, run slideshows, and take snapshots.

● Image I/O. A framework for reading image data from a source and for writing image data to a destination.Sources and destinations can be URLs, Core Foundation data objects, and Quartz data consumers anddata providers.

● Core Image. A framework that gives your application access to built-in image filters for both video andstill images and allows you to create custom image filters. Examples of built-in filters are those that crop,blur, and warp images. Core Image is implemented by the Quartz Core framework(QuartzCore.framework).

● Image Capture Services. A collection of frameworks that enables your application to browse locallyconnected or networked scanners and cameras, to list and download thumbnails and images, to takescans, rotate and delete images and, if the device supports it, to take pictures or control the scan parameters.

Color ManagementColorSync is the color management system for Mac OS X. It provides essential services for fast, consistent, andaccurate color calibration, proofing, and reproduction as well as an interface for accessing and managingsystemwide color management settings. It also supports color calibration with hardware devices such asprinters, scanners, and displays.

In most cases, you do not need to call ColorSync functions at all. Quartz and Cocoa automatically use ColorSyncto manage pixel data when drawing on the screen. They also respect ICC (International Color Consortium)profiles and apply the system’s monitor profile as the source color space. However, you might need to useColorSync directly if you define a custom color management module (CMM), which is a component thatimplements color-matching, color-conversion, and gamut-checking services.

For information about the ColorSync API, see ColorSync Manager Reference . For additional information aboutthe gamma changes introduced in Mac OS X v10.6, see “OS X v10.6 Snow Leopard” in What’s New in Mac OS X .

Media LayerGraphics Technologies

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

38

Page 39: OSX Technology Overview

PrintingPrinting support in Mac OS X is implemented through a collection of APIs and system services available to allapplication environments. Drawing on the capabilities of Quartz, the printing system delivers a consistenthuman interface and makes shorter development cycles possible for printer vendors. It also provides applicationswith a high degree of control over the user interface elements in printing dialogs. Table 3-2 describes someother features of the Mac OS X printing system.

Table 3-2 Features of the Mac OS X printing system

DescriptionFeature

Common Unix Printing System (CUPS), an open-source architecture usedto handle print spooling and other low-level features, provides theunderlying support for printing.

CUPS

Desktop printers offer users a way to manage printing and print jobs fromthe Dock or desktop.

Desktop printers

Fax support means that users can fax documents directly from the Printdialog.

Fax support

GNU Image Manipulation Program (GIMP) provides drivers for many olderprinters.

GIMP-Print drivers

PDF as a native data type lets any application easily save textual andgraphical data to device-independent PDF.

Native PDF (support for)

PostScript support allows applications to print to PostScript Level2–compatible and Level 3–compatible printers and to convert PostScriptfiles directly to PDF.

PostScript support

The print preview capability lets users see documents through a PDFviewer application prior to printing.

Print preview

Printer discovery enables users to detect, configure, and add to printerlists those printers that implement Bluetooth or Bonjour.

Printer discovery

Raster printers are supported in all environments.Raster printers (supportfor)

Speedy spooling enables applications that use PDF to submit PDF filesdirectly to the printing system instead of spooling individual pages.

Speedy spooling

For an overview of the printing architecture and how to support it, see Mac OS X Printing System Overview .

Media LayerGraphics Technologies

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

39

Page 40: OSX Technology Overview

Audio TechnologiesMac OS X includes support for high-quality audio recording, synthesis, manipulation and playback. Theframeworks in the following list are ordered from high level to low level, with the AV Foundation frameworkoffering the highest-level interfaces you can use. When choosing an audio technology, remember thathigher-level frameworks are easier to use and are generally preferred. Lower-level frameworks offer moreflexibility and control but require you to do more work.

● AV Foundation. A framework that supports audio playback, editing, and recording. Unless you are creatinga game or a VoIP application, look first at AV Foundation for your audio needs.

● OpenAL. A framework implementing a cross-platform standard API for 3D audio. It lets you implementhigh-performance positional playback in games and other applications

● Core Audio. A set of frameworks that provide audio services such as recording, playback, synchronization,signal processing, format conversion, panning and surround sound.

For information about each of the audio frameworks, read the corresponding entry in “Media LayerFrameworks” (page 41).

Video TechnologiesWhether you are playing movie files from your application or streaming them from the network, Mac OS Xprovides several technologies to play your video-based content. On systems with the appropriate hardware,you can also use these technologies to capture video and incorporate it into your application.

When choosing a video technology, remember that the higher-level frameworks simplify the work you haveto do to support the features you need and are generally recommended. The frameworks in the following listare ordered from highest to lowest level, with the AV Foundation framework offering the highest-level interfacesyou can use.

● AV Foundation. This framework is the primary technology in Mac OS X for playing, recording, reading,encoding, writing, and editing audiovisual media.

● Core Media. A framework that publishes a low-level C interface for managing and playing audiovisualmedia. With the Core Media I/O framework, you can create plug-ins that can access media hardware andthat can capture video and mixed audio and video streams.

● Core Video. A framework that provides a pipeline model for digital video between a client and the GPUto deliver hardware-accelerated video processing while allowing access to individual frames. Use CoreVideo only if your application needs to manipulate individual video frames.

Media LayerAudio Technologies

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

40

Page 41: OSX Technology Overview

For information about each of the video frameworks (as well as other frameworks) in the Media layer, see“Media Layer Frameworks” (page 41).

Media Layer FrameworksMac OS X includes numerous technologies for rendering and animating 2D and 3D content (including text)and for playing, recording, and editing audiovisual media.

Application Services Umbrella FrameworkThe Application Services umbrella framework (ApplicationServices.framework) includes the followingsubframeworks as well the ColorSync framework, described in “Color Management” (page 38). You shouldnot link with these frameworks directly; instead link with (and import) ApplicationServices.framework.

Core GraphicsThe Quartz 2D client API offered by the Core Graphics framework (CoreGraphics.framework) providescommands for managing the graphics context and for drawing primitive shapes, images, text, and othercontent. The Core Graphics framework defines the Quartz 2D interfaces, types, and constants you use in yourapplications.

The Quartz Services API (which is also part of the Core Graphics framework) provides direct access to somelow-level features of the window server. You can use this API to get information about the currently connecteddisplay hardware, capture a display for exclusive use, or adjust display attributes, such as its resolution, pixeldepth, and refresh rate. Quartz Services also provides some support for operating a Mac OS X system remotely.

Quartz 2D provides many important features to user applications, including the following:

● High-quality rendering on the screen

● Resolution independent UI support

● Anti-aliasing for all graphics and text

● Support for adding transparency information to windows

● Internal compression of data

● A consistent feature set for all printers

● Automatic PDF generation and support for printing, faxing, and saving as PDF

● Color management through ColorSync

Table 3-3 describes some of technical specifications for Quartz 2D

Media LayerMedia Layer Frameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

41

Page 42: OSX Technology Overview

Table 3-3 Quartz 2D technical specifications

A minimum bit depth of 16 bits for typical users.Bit depth

Supports 800 pixels by 600 pixels as the minimum screen resolution fortypical users. A resolution of 640 x 480 is available for the iBook.

Minimum resolution

Quartz takes advantage of any available vector unit hardware to boostperformance.

Velocity Engine and SSEsupport

Quartz Extreme uses OpenGL to draw the entire Mac OS X desktop.Graphics calls render in supported video hardware, freeing up the CPUfor other tasks.

Quartz Extreme

For information about the Quartz 2D API, see Quartz 2D Programming Guide . For information about the QuartzServices API, see Quartz Display Services Programming Topics .

Core TextCore Text is a C-based API that provides you with precise control over text layout and typography. Core Textprovides a layered approach to laying out and displaying Unicode text. You can modify as much or as little ofthe system as suits your needs. Core Text also provides optimized configurations for common scenarios, savingsetup time in your application.

The Core Text font API is complementary to the Core Text layout engine. Core Text font technology is designedto handle Unicode fonts natively and comprehensively, unifying disparate Mac OS X font facilities so thatdevelopers can do everything they need to do without resorting to other APIs.

For more information about Core Text, see Core Text Programming Guide and Core Text Reference Collection .

Image I/OApplications can use the Image I/O framework to read and write image data in most file formats in a highlyefficient manner. It offers very fast image encoding and decoding facilities, supports image metadata andcaching, provides color management, and is able to load image data incrementally.

The central objects in Image I/O are image sources and image destinations. Sources and destinations can beURLs (CFURLRef), data objects (CFDataRef and CFMutableDataRef), and Quartz data consumer and providerobjects (CGDataConsumerRef and CGDataProviderRef).

The Image I/O programmatic interfaces were once part of Quart 2D (Core Graphics), but have been collectedin an separate framework so that applications can use it independently of Core Graphics. To learn more aboutImage I/O, see Image I/O Programming Guide .

Media LayerMedia Layer Frameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

42

Page 43: OSX Technology Overview

AV FoundationIntroduced in Mac OS X v10.7, the AV Foundation framework (AVFoundation.framework) provides servicesfor capturing, playing, inspecting, editing, and reencoding time-based audiovisual media. The frameworkincludes many Objective-C classes, with the core class being AVAsset; this class presents a uniform modeland inspection interface for all forms and sources of audiovisual media. The services offered by this frameworkinclude:

● Movie or audio capture

● Movie or audio playback, including precise synchronization and audio panning

● Media editing and track management

● Media asset and metadata management

● Audio file inspection (for example, data format, sample rate, and number of channels)

For most audio recording and playback requirements, you can use the AVAudioPlayer and AVAudioRecorderclasses.

AV Foundation is the recommended API for all new development involving time-based audiovisual media. AVFoundation is also recommended for transitioning existing applications that were based on QuickTime orQTKit.

Note The AV Foundation frameworks for Mac OS X and iOS are almost identical.

For more information about the classes of the AV Foundation framework, see AV Foundation ProgrammingGuide .

ColorSyncThe ColorSync framework (ColorSync.framework) implements the color management system for Mac OSX. To find out more about ColorSync, see “Color Management” (page 38).

The ColorSync framework is a subframework of the Application Services umbrella framework. Your projectcannot link to it directly; it must link instead to ApplicationServices.framework.

Core AudioCore Audio consists of a group of frameworks that offer sophisticated services for manipulating multichannelaudio. (Core Audio is also the name of one framework of this group.) You can use Core Audio to generate,record, mix, edit, process, and play audio. You can also use Core Audio to work with MIDI (Musical InstrumentDigital Interface) data using both hardware and software MIDI instruments. The frameworks of Core Audio are:

Media LayerMedia Layer Frameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

43

Page 44: OSX Technology Overview

● Core Audio (CoreAudio.framework). Provides interfaces that allow your application to interact withaudio hardware and obtain and convert the host's time base. It also defines data types used throughoutthe Core Audio frameworks.

● Core Audio Kit (CoreAudioKit.framework). Objective-C classes that provide user interfaces for audiounits.

● Audio Toolbox (AudioToolbox.framework). Provides general audio services to applications, such asaudio converters and audio processing graphs, reading and writing audio data in files, managing andplaying event tracks, and assigning and reading audio format metadata.

● Audio Unit (AudioUnit.framework). Defines programmatic interfaces for creating and manipulatingaudio units, plug-ins for handling or generating audio signals.

● Core MIDI (CoreMIDI.framework). Provides MIDI support for applications, allowing them to communicatewith MIDI devices, to configure or customize the global state of the MIDI system, and to create MIDIplay-through connections between MIDI sources and destinations.

Most Core Audio interfaces are C-based, providing a low-latency and flexible programming environment thatis suitable for real-time applications. You can use Core Audio from any Mac OS X program. Some of the benefitsof Core Audio include the following:

● Built-in support for reading and writing a wide variety of audio file and data formats

● Plug-in support for custom formats, audio synthesis, and processing (audio DSP)

● A modular approach for constructing audio signal chains

● Easy MIDI synchronization

● Support for scheduled playback and synchronization with access to timing and control information

● A standardized interface to all built-in and external hardware devices, regardless of connection type (USB,Firewire, PCI, and so on)

Audio queue objects give you access to incoming or outgoing raw audio data while the system handles memorymanagement and hardware connections. Starting in Mac OS X v10.7, you can intercept and process audio asit proceeds through an audio queue object. This real-time, callback-based feature is known as audio queueprocessing taps . This feature works for input (such as for recording) as well as output (such as for playback).Audio queue processing taps let you insert audio units or other forms of audio processing, effectively tappinginto and modifying the data stream within an audio queue. You can also use this technology in a siphon modein which you gain access to the stream but do not modify it.

For an overview of Core Audio and its features, see Core Audio Overview . For reference information, see CoreAudio Framework Reference .

Media LayerMedia Layer Frameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

44

Page 45: OSX Technology Overview

Instant MessagingMac OS X provides two technologies to support instant messaging:

● The Instant Message framework (InstantMessage.framework) supports the detection and display ofa user’s online presence in applications other than iChat. You can find out the current status of a userconnected to an instant messaging service, obtain the user’s custom icon and status message, or obtaina URL to a custom image that indicates the user’s status.

You can use the Instant Message framework to support iChat Theater. This feature gives your applicationthe ability to inject audio or video content into a running iChat conference.

● Introduced in Mac OS X v10.7, the Instant Message Service Plug-in framework(IMServicePlugin.framework) enables the creation of bundle plug-ins that let applications talk toinstant-messaging services other than AIM and Jabber, such as to iChat. It includes support for the buddylist, handle availability, handle icon, status messages, instant messaging, and group-chat messaging.

For more information about using the Instant Message framework, see Instant Message Programming Guide .For more information about the Instant Message Service Plug-in framework, see IMServicePlugIn ProtocolReference and IMServicePlugInInstantMessagingSupport Protocol Reference

OpenALThe Open Audio Library (OpenAL.framework) is a cross-platform standard API for delivering 3D audio. OpenALlets you implement high-performance positional playback in games and other programs. Because it is across-platform standard, applications you write using OpenAL in Mac OS X can be ported to run on many otherplatforms.

OpenAL in Mac OS X supports audio capture, exponential and linear distance models, location offsets, andspatial effects such as reverb and occlusion. The Mac OS X implementation of OpenAL also supports certainCore Audio features such as mixer sample rates.

For more information on the Mac OS X implementation of OpenAL, go to http://developer.apple.com/audio/ope-nal.html. The OpenAL specification is described at http://www.openal.org.

OpenGLOpenGL is an industry-wide standard for developing portable three-dimensional (3D) graphics applications. Itis specifically designed for applications such as games that need a rich, robust framework for visualizing shapesin two and three dimensions. The OpenGL API is one of the most widely adopted graphics API standards, whichmakes code written for OpenGL portable and consistent across platforms. The OpenGL framework(OpenGL.framework) in Mac OS X includes a highly optimized implementation of the OpenGL libraries thatprovides high-quality graphics at a consistently high level of performance.

Media LayerMedia Layer Frameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

45

Page 46: OSX Technology Overview

OpenGL offers a broad and powerful set of imaging functions, including texture mapping, hidden surfaceremoval, alpha blending (transparency), anti-aliasing, pixel operations, viewing and modeling transformations,atmospheric effects (fog, smoke, and haze), and other special effects. Each OpenGL command directs a drawingaction or causes a special effect, and developers can create lists of these commands for repetitive effects.Although OpenGL is largely independent of the windowing characteristics of each operating system, thestandard defines special glue routines to enable OpenGL to work in an operating system’s windowingenvironment. The Mac OS X implementation of OpenGL implements these glue routines to enable operationwith the Quartz Compositor.

OpenGL supports the ability to use multiple threads to process graphics data. OpenGL also supports pixelbuffer objects, color-managed texture images in the sRGB color space, and 64-bit addressing. It also offersimprovements in the shader programming API.

Beginning in Mac OS X v10.6, support was added for OpenGL 2.1, which has many new extensions for addedfunctionality. Mac OS X v10.7 added support for Open GL 3.2 Core, which added more extensions as baselinefeatures. The newest version of OpenGL deprecates routines and mechanisms found in OpenGL 1.n and OpenGL2.n , including the removal of the fixed-function pipeline that was the main approach to developing OpenGL1.n applications. An OpenGL 3.2 application requires you to create your own shader strategy rather thanassuming that a standard graphics pipeline will do everything. As a result, for simple applications you need towrite more boilerplate code than was required by previous versions of OpenGL.

For information about using OpenGL in Mac OS X, see OpenGL Programming Guide for Mac OS X .

QuartzThe Quartz umbrella framework includes the following subframeworks. You should not link directly with anyof the subframeworks; instead link with (and import) Quartz.framework.

Image KitThe Image Kit framework is an Objective-C framework that makes it easy to incorporate powerful imagingservices into your applications. This framework takes advantage of features in Quartz, Core Image, OpenGL,and Core Animation to provide an advanced and highly optimized development path for implementing thefollowing features:

● Displaying images

● Rotating, cropping, and performing other image-editing operations

● Browsing for images

● Taking pictures using the built-in picture taker panel

● Displaying slideshows

Media LayerMedia Layer Frameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

46

Page 47: OSX Technology Overview

● Browsing for Core Image filters

● Displaying custom views for Core Image filters

For more information on how to use Image Kit, see Image Kit Programming Guide and Image Kit ReferenceCollection

PDF KitPDF Kit is a Cocoa framework for managing and displaying PDF content directly from your application’s windowsand dialogs. You can embed a PDFView object in your window and give it a PDF file to display. The PDF viewhandles the rendering of the PDF content, handles copy-and-paste operations, and provides controls fornavigating and setting the zoom level. Other classes let you get the number of pages in a PDF file, find text,manage selections, add annotations, and specify the behavior of some graphical elements, among other actions.

For more information on PDF Kit, see PDF Kit Programming Guide .

Quartz ComposerThe Quartz Composer framework (QuartComposer.framework) provides programmatic support for dealingwith Quartz Composer compositions. It enables applications to load, play, and control compositions, includingthose in Core Animation layers.

For more information, see Quartz Composer Programming Guide .

Quick Look UIThe Quick Look UI framework (QuickLookUI.framework), introduced in Mac OS X v10.6, defines an interfacefor implementing a Quick Look preview panel, which displays the preview of a list of items. In Mac OS X v10.7,the framework added the capability for embedding a preview inside a view.

For an example of an application that implements Quick Look preview panels, see QuickLookDownloader .

Quartz CoreThe Quartz Core framework (QuartzCore.framework) implements two important system technologies forgraphics and imaging, Core Animation and Core Image.

Core AnimationCore Animation is a set of Objective-C classes for doing sophisticated 2D rendering and animation. Using CoreAnimation, you can create everything from basic window content to carousel–style user interfaces (such asFront Row’s), and achieve respectable animation performance without having to tune your code using OpenGL

Media LayerMedia Layer Frameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

47

Page 48: OSX Technology Overview

or other low-level drawing routines. This performance is achieved using server-side content caching, whichrestricts the compositing operations performed by the server to only those parts of a view or window whosecontents actually change.

At the heart of the Core Animation programming model are layer objects, which are similar in many ways toCocoa views. As with views, you can arrange layers in hierarchies, change their size and position, and tell themto draw themselves. Unlike views, layers do not support event-handling, accessibility, or drag and drop.

You can manipulate the layout of layers in more ways than the layout of traditional Cocoa views. In additionto positioning layers using a layout manager, you can apply 3D transforms to layers to rotate, scale, skew, ortranslate them in relation to their parent layer. In Mac OS X v10.7 and later, you can create a layer tree in oneprocess and display it in another.

Layer content can be animated implicitly or explicitly depending on the actions you take. Modifying specificproperties of a layer, such as its geometry, visual attributes, or children, typically triggers an implicit animationto transition from the old state to the new state of the property. For example, adding a child layer triggers ananimation that causes the child layer to fade gradually into view. You can also trigger animations explicitly ina layer by modifying its transformation matrix.

You can manipulate layers independent of, or in conjunction with, the views and windows of your application.Cocoa applications can take advantage of the Core Animation’s integration with the NSView class to addanimation effects to windows. Layers can also support the following types of content:

● Quartz and Cocoa drawing content

● OpenGL content

● Quartz Composer compositions

● Core Image filter effects

For information about Core Animation, see Animation Overview .

Core ImageCore Image extends the basic graphics capabilities of the system to provide a framework for implementingcomplex visual behaviors in your application. Core Image uses GPU-based acceleration and 32-bit floating-pointsupport to provide fast image processing and pixel-level accurate content. Its plug-in–based architecture letsyou expand the capabilities of Core Image through the creation of image units, which implement the desiredvisual effects.

Core Image includes built-in image units that allow you to:

● Crop, composite, blur, and sharpen images

Media LayerMedia Layer Frameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

48

Page 49: OSX Technology Overview

● Correct color, including perform white-point adjustments

● Apply color effects, such as sepia tone

● Warp the geometry of an image by applying an affine transform or a displacement effect

● Generate color, checkerboard patterns, Gaussian gradients, and other pattern images

● Add transition effects to images or video

● Provide real-time control, such as color adjustment and support for sports mode, vivid mode, and othervideo modes

● Apply linear lighting effects, such as spotlight effects

You can use both the built-in and custom image units in your application to implement special effects andperform other types of image manipulations. Beginning in Mac OS X v10.7, Core Image supports face detection;this feature detects faces in an image, yielding for each found face its bounds within the image and eye andmouth positions.

For information about how to use Core Image or how to write custom image units, seeCore ImageProgrammingGuide and Core Image Reference Collection . For information about the built-in filters in Core Image, see CoreImage Filter Reference .

QuickTime KitThe QuickTime Kit (QTKit.framework), or QTKit, is an Objective-C framework for manipulating QuickTime-basedmedia. This framework lets you incorporate movie playback, movie editing, export to standard media formats,and other QuickTime behaviors easily into your applications.

Note “AV Foundation” (page 43) is the recommended API for all new development involvingtime-based audiovisual media. AV Foundation is also recommended for transitioning existingapplications that were based on QuickTime or QTKit.

Other Media Layer FrameworksThe Media layer of Mac OS X also has the following frameworks:

● Core Media. Introduced in Mac OS X v10.7, Core Media (CoreMedia.framework) provides a low-level Cinterface for managing and playing audiovisual media in an application. It also defines the fundamentaltime representation used uniformly throughout AV Foundation.

Media LayerMedia Layer Frameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

49

Page 50: OSX Technology Overview

Introduced in Mac OS X v10.7, Core Media I/O framework (CoreMediaIO.framework) publishes theDevice Abstraction Layer (DAL) plug-in API. This technology enables you to create plug-ins that can accessmedia hardware and capture video and “muxed” (video combined with audio) streams. This API is areplacement for the QuickTime VDig API.

For information, see Core Media Framework Reference .

● Core Video. Creates a bridge between QuickTime and the graphics card’s GPU to deliverhardware-accelerated video processing. Benefits of Core Video include filters and effects, per-pixel accuracy,and hardware scalability.

For information about using the Core Video framework, see Core Video Programming Guide .

● Disc Recording.Gives applications the ability to burn and erase CDs and DVDs. Your application specifiesthe content to be burned but the framework (DiscRecording.framework) takes over the process ofbuffering the data, generating the proper file format information, and communicating everything to theburner. The Disc Recording UI framework (DiscRecordingUI.framework) provides a complete, standardset of windows for gathering information from the user and displaying the progress of the burn operation.

For more information, seeDiscRecordingFrameworkReference andDiscRecordingUI FrameworkReference .

● DVD Playback.Embeds DVD viewer capabilities into an application. You use the framework(DVDPlayback.framework) to control various aspects of playback, including menu navigation, viewerlocation, angle selection, and audio track selection. You can play back DVD data from disc or from a localVIDEO_TS directory.

For more information about using the DVD Playback framework, see DVD Playback Services ProgrammingGuide .

● Image Capture. The Image Capture Core framework is a high-level framework for capturing image datafrom scanners and digital cameras. The interfaces of the framework (ImageCaptureCore.framework)are device-independent, so you can use it to gather data from any devices connected to the system. Youcan get a list of devices, retrieve information about a specific device or image, and retrieve the image dataitself.

This framework works in conjunction with the Image Capture Devices framework (ICADevices.framework)to communicate with imaging hardware. For information on using these frameworks, see Image CaptureApplications Programming Guide .

Media LayerMedia Layer Frameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

50

Page 51: OSX Technology Overview

This chapter summarizes the core services technologies that are most relevant to developers. They are calledcore services because they provide essential services to apps but have no direct bearing on the user interfacean app presents to users. They generally are dependent on frameworks and technologies in the Core OS layerand in Kernel and Device Drivers layer of Mac OS X.

If you are new to developing Mac OS X software, you should read through this chapter at least once tounderstand the available core-service technologies and how you might use them in your software. Evenexperienced developers should revisit this chapter periodically to remind themselves of the availabletechnologies.

High-Level FeaturesThe following sections describe some of the key technologies available in the Core Services layer.

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

51

Core Services Layer

Page 52: OSX Technology Overview

iCloud StorageWhen you use the iCloud storage APIs, your app writes user documents and data to a central location. A usercan view or edit those documents from any device without having to sync or transfer files explicitly. Storingdocuments in a user’s iCloud account also provides a layer of security for that user. Even if a user loses a device,the documents on that device are not lost if they are in iCloud storage.

There are two types of iCloud storage that your app can take advantage of:

● Use iCloud document storage to store user documents and data in the user’s iCloud account.

● Use iCloud key-value data storage to share small amounts of data among instances of your app.

Most apps will use iCloud document storage to share documents from a user’s iCloud account. This is thefeature that users think of when they think of iCloud storage. A user cares about whether documents are sharedacross devices and can see and manage those documents from a given device. In contrast, the iCloud key-valuedata store is not something a user sees. It is a way for your app to share very small amounts of data (tens ofkilobytes) with other instances of itself. Apps should use this feature to store noncritical app data, such aspreferences, rather than important app data.

To learn more about adding iCloud storage to your app, read “iCloud Storage” in Mac App Programming Guide .

Core Services LayerHigh-Level Features

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

52

Page 53: OSX Technology Overview

Automatic Reference CountingAutomatic Reference Counting (ARC) is a compiler-level feature that simplifies the process of managing thelifetimes of Objective-C objects. Instead of you having to remember when to retain or release an object, ARCevaluates the lifetime requirements of your objects and automatically inserts the appropriate method calls atcompile time.

ARC replaces the traditional managed memory model style of programming found in earlier versions of MacOS X. Any new projects you create automatically use ARC. And Xcode provides migration tools to help convertexisting projects to use ARC. For more information about how to perform this migration, see What's New InXcode . For more information about ARC itself, see Transitioning to ARC Release Notes .

File CoordinationFile coordination, introduced in Mac OS X v10.7, eliminates file-system inconsistencies due to overlapping readand write operations from competing processes. When you use the NSDocument class from the AppKitframework, you get file coordination with very little effort. To use file coordination explicitly, you employ theNSFileCoordinator class and the NSFilePresenter protocol, both from the Foundation framework.

The file coordination APIs let you assert your app’s ownership of files and directories. When another processattempts access, you have a chance to respond. For example, if another app attempts to read a document thatyour app is editing, you have a chance to write unsaved changes to disk before the other app is allowed to doits reading.

Core Services LayerHigh-Level Features

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

53

Page 54: OSX Technology Overview

You use file coordination only with files that users conceivably might share with other users, not (for example)with files written to cache or temporary locations. File coordination is an enabling technology for automaticdocument saving, App Sandbox, and other features introduced in Mac OS X v10.7. For more information onfile coordination, see “Coordinating File Access With Other Processes” in Mac App Programming Guide .

Bundles and PackagesA feature integral to Mac OS X software distribution is the bundle mechanism. Bundles encapsulate relatedresources in a hierarchical file structure but present those resources to the user as a single entity. Programmaticinterfaces make it easy to find resources inside a bundle. These same interfaces form a significant part of theMac OS X internationalization strategy.

Apps and frameworks are only two examples of bundles in Mac OS X. Plug-ins, screen savers, and preferencepanes are all implemented using the bundle mechanism as well. Developers can also use bundles for theirdocument types to make it easier to store complex data.

Packages are another technology, similar to bundles, that make distributing software easier. A package—alsoreferred to as an installation package—is a directory that contains files and directories in well-defined locations.The Finder displays packages as files. Double-clicking a package launches the Installer application, which theninstalls the contents of the package on the user’s system.

For an overview of bundles and how they are constructed, see Bundle Programming Guide .

Internationalization and LocalizationLocalizing your app is necessary for success in many foreign markets. Users in other countries are much morelikely to buy your software if the text and graphics reflect their own language and culture. Before you canlocalize an app, though, you must design it in a way that supports localization, a process calledinternationalization. Properly internationalizing an app makes it possible for your code to load localized contentand display it correctly.

Internationalizing an app involves the following steps:

● Use Unicode strings for storing user-visible text.

● Extract user-visible text into “strings” resource files.

● Use nib files to store window and control layouts whenever possible.

● Use international or culture-neutral icons and graphics whenever possible.

● Use Cocoa or Core Text to handle text layout.

● Support localized file-system names (also known as “display names”).

Core Services LayerHigh-Level Features

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

54

Page 55: OSX Technology Overview

● Use formatter objects in Core Foundation and Cocoa to format numbers, currencies, dates, and timesbased on the current locale.

For details on how to support localized versions of your software, see Internationalization Programming Topics .For information on Core Foundation formatters, see Data Formatting Guide for Core Foundation .

BlocksIntroduced in Mac OS X v10.6, blocks are a C-level mechanism that you can use to create an ad hoc functionbody as an inline expression in your code. In other languages and environments, a block is sometimes calleda closure or a lambda . You use blocks when you need to create a reusable segment of code but defining afunction or method might be a heavyweight (and perhaps inflexible) solution—for example, if you want towrite callbacks with custom data or if you want to perform an operation on all the items in a collection.

The compiler provides support for blocks using the C, C++, and Objective-C languages. For more informationabout how to create and use blocks, see Blocks Programming Topics .

Grand Central DispatchIntroduced in Mac OS X v10.6, Grand Central Dispatch (GCD) provides a simple and efficient API for achievingthe concurrent execution of code in your app. Instead of threads, GCD provides the infrastructure for executingany task in your app asynchronously using a dispatch queue. Dispatch queues collect your tasks and workwith the kernel to facilitate their execution on an underlying thread. A single dispatch queue can execute tasksserially or concurrently and apps can have multiple dispatch queues executing tasks in parallel.

There are several advantages to using dispatch queues over traditional threads. One of the most important isperformance. Dispatch queues work more closely with the kernel to eliminate the normal overhead associatedwith creating threads. Serial dispatch queues also provide built-in synchronization for queued tasks, eliminatingmany of the problems normally associated with synchronization and memory contention normally encounteredwhen using threads.

In addition to dispatch queues, GCD provides other interfaces to support the asynchronous design approachoffered by dispatch queues:

● Dispatch sources provide a way to handle the following types of kernel-level events that is more efficientthan BSD alternatives:

● Timer notifications

● Signal handling

● Events associated with file and socket operations

● Significant process-related events

● Mach-related events

Core Services LayerHigh-Level Features

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

55

Page 56: OSX Technology Overview

● Custom events that you define and trigger

● Dispatch groups allow one thread (or task) to block while it waits for one or more other tasks to finishexecuting.

● Dispatch semaphores provide a more efficient alternative to the traditional semaphore mechanism.

Starting in Mac OS X v10.7, GCD supports asynchronous I/O through dispatch data and dispatch I/O.

For more information about how to use GCD in your apps, see Concurrency Programming Guide .

BonjourBonjour is Apple’s implementation of the zero-configuration networking architecture, a powerful system forpublishing and discovering services over an IP network. It is relevant to both software and hardware developers.

Incorporating Bonjour support into your software improves the overall user experience. Rather than promptthe user for the exact name and address of a network device, you can use Bonjour to obtain a list of availabledevices and let the user choose from that list. For example, you could use it to look for available printingservices, which would include any printers or software-based print services, such as a service to create PDFfiles from print jobs.

Developers of network-based hardware devices are strongly encouraged to support Bonjour. Bonjour alleviatesthe need for complicated setup instructions for network-based devices such as printers, scanners, RAID servers,and wireless routers. When plugged in, these devices automatically publish the services they offer to clientson the network.

For information on how to incorporate Bonjour services into a Cocoa app, see Bonjour Overview . Bonjour fornon-Cocoa apps is described in DNS Service Discovery Programming Guide .

Security ServicesMac OS X security is built upon several open source technologies, including BSD and Kerberos and adds itsown features to those technologies. The Security framework (Security.framework) implements a layer ofhigh-level services to simplify your security solutions. These high-level services provide a convenient abstractionand make it possible for Apple and third parties to implement new security features without breaking yourcode. They also make it possible for Apple to combine security technologies in unique ways.

Mac OS X provides high-level interfaces for the following features:

● User authentication

● Certificate, key, and trust services

● Authorization services

Core Services LayerHigh-Level Features

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

56

Page 57: OSX Technology Overview

● Secure transport

● Keychain Services

Security Transforms, a technology which was introduced in Mac OS X v10.7, provide a universal context for allcryptographic work. A cryptographic unit in Security Transforms, known as a SecTransform, can be used inmultiple ways. There are SecTransforms for encryption, decryption, signing, verifying, digesting, and encoding.You can also create custom SecTransforms. SecTransforms are built upon GCD and define a data-flow modelfor processing data that allows much greater throughput on multicore machines.

Note Beginning in Mac OS X v10.7, CDSA (Common Data Security Architecture) has been deprecatedand its use discouraged. Instead, use the Security Transform technology.

Mac OS X supports many network-based security standards; for a complete list of network protocols, see“Standard Network Protocols” (page 77). For more information about the security architecture andsecurity-related technologies of Mac OS X, see Security Overview .

Speech TechnologiesMac OS X contains speech technologies that recognize and speak U.S. English. These technologies providebenefits for users and present the possibility of a new paradigm for human-computer interaction.

Speech recognition is the ability for the computer to recognize and respond to a person’s speech. Usingspeech recognition, users can accomplish tasks comprising multiple steps with one spoken command. Becauseusers control the computer by voice, speech-recognition technology is very important for people with specialneeds. You can take advantage of the speech engine and API included with Mac OS X to incorporate speechrecognition into your apps.

Speech synthesis, also called text-to-speech (TTS), converts text into audible speech. TTS provides a way todeliver information to users without forcing them to shift attention from their current task. For example, thecomputer could deliver messages such as “Your download is complete” and “You have email from your boss;would you like to read it now?” in the background while you work. TTS is crucial for users with vision or attentiondisabilities. As with speech recognition, TTS provides an API and several user interface features to help youincorporate speech synthesis into your apps. You can also use speech synthesis to replace digital audio filesof spoken text. Eliminating these files can reduce the overall size of your software bundle.

For more information, see Speech Synthesis Programming Guide and NSSpeechRecognizer Class Reference .

Core Services LayerHigh-Level Features

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

57

Page 58: OSX Technology Overview

Identity ServicesIdentity Services encompasses features located in the Collaboration and Core Services frameworks. IdentityServices provides a way to manage groups of users on a local system. In addition to standard login accounts,administrative users can now create sharing accounts, which use access control lists to restrict access todesignated system or app resources. Sharing accounts do not have an associated home directory on the systemand have much more limited privileges than traditional login accounts.

For more information about the features of Identity Services and how you use those features in your apps, seeIdentity Services Programming Guide and Identity Services Reference Collection .

Time Machine SupportThe Time Machine feature protects user data from accidental loss by automatically backing up data to a differenthard drive. Included with this feature is a set of programmer-level functions that you can use to excludeunimportant files from the backup set. For example, you might use these functions to exclude your app’s cachefiles or any files that can be recreated easily. Excluding these types of files improves backup performance andreduces the amount of space required to back up the user’s system.

For information about the new functions, see Backup Core Reference .

Keychain ServicesKeychain Services provides a secure way to store passwords, keys, certificates, and other sensitive informationassociated with a user. Users often have to manage multiple user IDs and passwords to access various loginaccounts, servers, secure websites, instant messaging services, and so on. A keychain is an encrypted containerthat holds passwords for multiple apps and secure services. Access to the keychain is provided through a singlemaster password. Once the keychain is unlocked, Keychain Services–aware apps can access authorizedinformation without bothering the user.

If your app handles passwords or sensitive information, you should add support for Keychain Services intoyour app. For more information on this technology, see Keychain Services Programming Guide .

XML ParsingMac OS X includes several XML parsing technologies. Most apps should use the Foundation classes:NSXMLParser for parsing XML streams and the NSXML classes (for example, NSXMLNode) for representingXML documents internally as tree structures. Core Foundation also provides a set of functions for parsing XMLcontent.

The open-source libXML2 library allows your app to parse or write arbitrary XML data quickly. The headersfor this library are located in the /usr/include/libxml2 directory.

Core Services LayerHigh-Level Features

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

58

Page 59: OSX Technology Overview

For information on parsing XML from a Cocoa app, see Event-Driven XML Programming Guide and Tree-BasedXML Programming Guide .

SQLite DatabaseThe SQLite library lets you embed a SQL database engine into your apps. Programs that link with the SQLitelibrary can access SQL databases without running a separate RDBMS process. You can create local databasefiles and manage the tables and records in those files. The library is designed for general purpose use but isstill optimized to provide fast access to database records.

The SQLite library is located at /usr/lib/libsqlite3.dylib and the sqlite3.h header file is in/usr/include. A command-line interface (sqlite3) is also available for communicating with SQLite databasesusing scripts. For details on how to use this command-line interface, see sqlite3 man page.

For more information about using SQLite, go to http://www.sqlite.org.

Distributed NotificationsA distributed notification is a message posted by any process to a per-computer notification center, which inturn broadcasts the message to any processes interested in receiving it. Included with the notification is theID of the sender and an optional dictionary containing additional information. The distributed notificationmechanism is implemented by the Core Foundation CFNotificationCenter object and by the CocoaNSDistributedNotificationCenter class.

Distributed notifications are ideal for simple notification-type events. For example, a notification mightcommunicate the status of a certain piece of hardware, such as the network interface or a typesetting machine.However, notifications should not be used to communicate critical information to a specific process. AlthoughMac OS X makes every effort possible, it does not guarantee the delivery of a notification to every registeredreceiver.

Distributed notifications are true notifications because there is no opportunity for the receiver to reply to them.There is also no way to restrict the set of processes that receive a distributed notification. Any process thatregisters for a given notification may receive it. Because distributed notifications use a string for the uniqueregistration key, there is also a potential for namespace conflicts.

For information on Core Foundation support for distributed notifications, see CFNotificationCenter Reference .For information about Cocoa support for distributed notifications, see Notification Programming Topics .

Core Services LayerHigh-Level Features

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

59

Page 60: OSX Technology Overview

Core Service FrameworksMac OS X includes several core services that make developing apps easier. These technologies range fromutilities for managing your internal data structures to high-level frameworks for speech recognition andaccessing calendar data. This section summarizes the technologies in the Core Services layer that are relevantto developers—that is, that have programmatic interfaces or have an impact on how you write software.

Core Services Umbrella FrameworkThe Core Services umbrella framework (CoreServices.framework) includes the following frameworks:

● Launch Services (LaunchServices.framework). Gives you a programmatic way to open apps, documents,URLs, or files with a given MIME type in a way similar to the Finder or the Dock. The Launch Servicesframework also provides interfaces for programmatically registering the document types your app supports.Lauch Services is in the Core Services umbrella framework.

For information on how to use Launch Services, see Launch Services Programming Guide .

● Metadata (Metadata.framework). Helps you to create Spotlight importer plug-ins. It also provides aquery API that you can use in your app to search for files based on metadata values and then sort theresults based on certain criteria. (The Foundation framework offers an Objective-C interface to the queryAPI.)

For more information on Spotlight importers, querying Spotlight, and the Metadata framework, seeSpotlight Importer Programming Guide and File Metadata Search Programming Guide .

● Search Kit (SearchKit.framework). Lets you search, summarize, and retrieve documents written inmost human languages. You can incorporate these capabilities into your app to support fast searching ofcontent managed by your app. This framework is part of the Core Services umbrella framework.

For detailed information about the available features, see Search Kit Reference .

● Web Services Core (WebServicesCore.framework). Provides support for the invocation of web servicesusing CFNetwork. The available services cover a wide range of information and include things such asfinancial data and movie listings. Web Services Core is part of the Core Services umbrella framework.

For a description of web services and information on how to use the Web Services Core framework, seeWeb Services Core Programming Guide .

● Dictionary Services (DictionaryServices.framework). Lets you create custom dictionaries that userscan access through the Dictionary app. Through these services, your app can also access dictionariesprogrammatically and can support user access to dictionary look-up through a contextual menu.

For more information, see Dictionary Services Programming Guide .

Core Services LayerCore Service Frameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

60

Page 61: OSX Technology Overview

You should not link directly to any of these subframeworks; instead link to (and import)CoreServices.framework.

Address BookAddress Book is technology that encompasses a centralized database for contact and group information, anapp for viewing that information, and a programmatic interface for accessing that information in your ownprograms. The database contains information such as user names, street addresses, email addresses, phonenumbers, and distribution lists. Apps that support this framework (AddressBook.framework) can use thisdata as-is or extend it to include app-specific information. They can share user records with other apps, suchas the Address Book app and the Apple Mail program.

Mac OS X v10.7 brings a number of enhancements to the Address Book framework. Your app can now use theAddress Book to access Exchange and CardDAV contacts. It can also allow users to display and edit contactsin a standardized user interface. The framework also now supports more instant-messaging services and yearlessdates.

For more information about this technology, see Address Book Programming Guide for Mac OS X and eitherAddress Book Objective-C Framework Reference for Mac OS X or Address Book C Framework Reference for MacOS X .

AutomatorThe Automator framework (Automator.framework) enables your app to run workflows, which string togetherthe actions defined by various apps to perform complex tasks automatically. Unlike AppleScript, which uses ascripting language to implement the same behavior, workflows are constructed visually, requiring no codingor scripting skills to create.

For information about incorporating workflows into your own apps, see Automator Framework Reference .

Core DataThe Core Data framework (CoreData.framework) manages the data model of an app in terms of theModel-View-Controller design pattern. Instead of defining data structures programmatically, you use the graphicaltools in Xcode to build a schema representing your data model. At runtime, entities are created, managed,and made available through the Core Data framework with little or no coding on your part.

Core Data provides the following features:

● Storage of object data in mediums ranging from an XML file to a SQLite database

● Management of undo/redo beyond basic text editing

● Support for validation of property values

Core Services LayerCore Service Frameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

61

Page 62: OSX Technology Overview

● Support for propagating changes and ensuring that the relationships between objects remain consistent

● Grouping, filtering, and organizing data in memory and transferring those changes to the user interfacethrough Cocoa bindings

Starting in Mac OS X v10.7, Core Data includes incremental storage, a work concurrency model, and nestedmanaged object contexts.

● Using the incremental store classes, NSIncrementalStore and NSIncrementalStoreNode, you cancreate Core Data stores that connect to any possible data source.

● The work concurrency model API enables your app to share unsaved changes between threads across theobject graph efficiently.

● You can create nested managed object contexts, in which fetch and save operations are mediated by theparent context instead of a coordinator. This pattern has a number of usage scenarios, including:

● Performing background operations on a second thread or queue

● Managing discardable edits, such as in an inspector window or view

For more information, see Core Data Programming Guide .

Foundation and Core FoundationThe Foundation and Core Foundation frameworks are essential to most types of software developed for MacOS X. The basic goals of both frameworks are the same:

● Define basic object behavior and introduce consistent conventions for memory management, objectmutability, object archiving, notifications, and similar behaviors.

● Define basic object types representing strings, numbers, dates, data, collections, and so on.

● Support internationalization with bundle technology and Unicode strings.

● Support object persistence.

● Provide utility classes that access and abstract system entities and services at lower layers of the system,including ports, threads, processes, run loops, file systems, and pipes.

The difference between Foundation (Foundation.framework) and Core Foundation (CoreFoundation.framework)is the language environment in which they are used. Foundation is an Objective-C framework and is intendedto be used with all other Objective-C frameworks that declare methods taking Foundation class types asparameters or with return values that are Foundation class types. Along with the AppKit and Core Dataframeworks, Foundation is considered to be a core framework for app development (see “Cocoa UmbrellaFramework” (page 31)). Core Foundation, on the other hand, declares C-based programmatic interfaces; it isintended to be used with other C-based frameworks such as Core Graphics.

Core Services LayerCore Service Frameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

62

Page 63: OSX Technology Overview

Note Although you can use Core Foundation objects and call Core Foundation functions inObjective-C projects, there is rarely a reason for doing so.

In its implementation, Foundation is based on Core Foundation. And, although it is C-based, the design of theCore Foundation interfaces is more object-oriented than C. As a result, the opaque types (often referred to asobjects) you create with Core Foundation interfaces operate seamlessly with the Foundation interfaces.Specifically, most equivalent Foundation classes and Core Foundation opaque types are toll-free bridged; thismeans that you can convert between object types through simple type-casting.

Foundation and Core Foundation provide basic data types and data management features, including thefollowing:

● Collections

● Bundles and plug-ins

● Strings

● Raw data blocks

● Dates and times

● Preferences

● Streams

● URLs

● XML data

● Locale information

● Run loops

● Ports and sockets

Starting in Mac OS X v10.7, the Foundation framework offers the following features:

● Regular expression support with the NSRegularExpression class.

● Streaming XML parsing with improvements to the NSXMLParser class.

● Conversion between JSON (Javascript Object Notation) data and Foundation types, with theNSJSONSerialization class.

● Decomposition of English sentences into their grammatical components with the NSLinguisticTaggerclass.

● Block-based enumeration of index sets by range, with convenience methods in the NSIndexSet class.

Core Services LayerCore Service Frameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

63

Page 64: OSX Technology Overview

● Support for ordered sets with the NSOrderedSet class, which combines features of the NSSet andNSArray classes.

In addition, in Mac OS X v10.7, the NSFileWrapper class is in the Foundation framework instead of in theAppKit framework.

For an overview of Foundation, read the introduction to Foundation Framework Reference . For an overview ofCore Foundation, read Core Foundation Design Concepts .

Quick LookQuick Look is a technology that enables apps such as Spotlight and the Finder display thumbnail images andfull-size previews of documents. If your app defines custom document formats that are different from thesystem-supported content types, you should provide a Quick Look generator for those formats. Generatorsare plug-ins that convert documents of the appropriate type from their native format to a format that QuickLook can display as thumbnails and previews to users.

In Mac OS X v10.7, Quick Look allows users of your app to preview the contents of a document embedded asa text attachment without requiring them to leave the app.

For information about supporting Quick Look for your custom document types, see Quick Look ProgrammingGuide and Quick Look Framework Reference for Mac . The related Quick Look UI framework is briefly describedin “Quick Look UI” (page 47).

Store KitStarting in Mac OS X v10.7, Store Kit (StoreKit.framework) enables you to request payment from a user topurchase additional app functionality or content from the Mac App Store.

Store Kit handles the financial aspects of a transaction, processing the payment request through the user’siTunes Store account. Store Kit then provides your app with information about the purchase. Your app handlesthe other aspects of the transaction, including the presentation of a purchasing interface and the downloading(or unlocking) of the appropriate content. This division of labor gives you control over the user experience.You also decide on the delivery mechanism that works best for your app.

For more information about Store Kit, read In-App Purchase Programming Guide and Store Kit FrameworkReference .

Core Services LayerCore Service Frameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

64

Page 65: OSX Technology Overview

WebKitThe WebKit framework (WebKit.framework) enables your app to display HTML content. It has twosubframeworks: Web Core and JavaScript Core. Web Core is for parsing and displaying HTML content; JavaScriptCore is for parsing and executing JavaScript code.

WebKit also lets you create text views containing editable HTML. With this basic editing support, users canreplace text and manipulate the document text and attributes, including CSS properties. WebKit also supportscreating and editing content at the DOM level of an HTML document. For example, you could extract the listof links on a page, modify them, and replace them prior to displaying the document in a web view.

For information on how to use WebKit, see WebKit Objective-C Programming Guide .

Other Frameworks in the Core Services LayerThe Core Services layer of Mac OS X also has the following frameworks:

● Calendar Store (CalendarStore.framework). Lets you access iCal data from an Objective-C based app.You can use this framework to fetch user calendars, events, and tasks from the iCal data storage, receivenotifications when those objects change, and make changes to the user’s calendar.

For information about using the Calendar Store framework, see Calendar Store Programming Guide .

● Collaboration (Collaboration.framework). Provides a set of Objective-C classes for displaying sharingaccount information and other identity-related user interfaces. With this API, apps can display informationabout users and groups and display a panel for selecting users and groups during the editing of accesscontrol lists. For related information, see “Identity Services” (page 58).

● Input Method Kit(InputMethodKit.framework). Helps you build input methods for Chinese, Japanese,and other languages. The framework handles tasks such as connecting to clients and running candidatewindows.

To learn more, see Input Method Kit Framework Reference .

● Latent Semantic Mapping (LatentSemanticMapping.framework). Supports the classification of textand other token-based content into developer-defined categories, based on semantic information latentin the text. Products of this technology are maps, which you can use to analyze and classify arbitrarytext—for example, to determine, if an email message is consistent with the user’s interests.

For information about the Latent Semantic Mapping framework, see Latent Semantic Mapping Reference .

Core Services LayerCore Service Frameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

65

Page 66: OSX Technology Overview

The technologies and frameworks in the Core OS layer of Mac OS X provide low-level services related tohardware and networks. These services are based on facilities in the Kernel and Device Drivers layer.

High-Level FeaturesThe Core OS layer implements features related to application security.

App SandboxIntroduced in Mac OS X v10.7, App Sandbox provides a last line of defense against stolen, corrupted, or deleteduser data if malicious code exploits your app. App Sandbox also minimizes the damage from coding errors. Itsstrategy is twofold:

1. App Sandbox enables you to describe how your app interacts with the system. The system then grantsyour app the access it needs to get its job done, and no more.

2. App Sandbox allows the user to transparently grant your app additional access by using Open and Savedialogs, drag and drop, and other familiar user interactions.

You describe your app’s interaction with the system by setting entitlements in Xcode. For details on all theentitlements available in Mac OS X, see Entitlement Key Reference .

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

66

Core OS Layer

Page 67: OSX Technology Overview

When you adopt App Sandbox, the system provides a special directory for use by your app—and only by yourapp—called a container . Your app has unfettered read/write access to the container. All Mac OS X path-findingAPIs, above the POSIX layer, are relative to the container instead of to the user’s home directory.

Your sandboxed app can access paths outside of its container in the following three ways:

● At the specific direction of the user, such as by using an Open or Save dialog

● By your configuring your app with entitlements for specific file-system locations, such as the Movies folder

● When a path is in any of certain directories that are world readable

Some app operations are more likely to be targets of malicious exploitation. Examples are the parsing of datareceived over a network, and the decoding of video frames. You can improve the effectiveness of the damagecontainment offered by App Sandbox by separating such potentially dangerous activities into their own addressspaces. For more information, see “XPC Interprocess Communication and Services” (page 71).

When you adopt App Sandbox, you must code sign your app (see “Code Signing” (page 67)). This is becauseentitlements, including the special entitlement that enables App Sandbox, are built into an app’s code signature.

For a complete explanation of App Sandbox and how to use it, read App Sandbox Design Guide .

Code SigningMac OS X employs the security technology known as code signing to allow you to certify that your app wasindeed created by you. After an app is code signed, the system can detect any change to the app—whetherthe change is introduced accidentally or by malicious code. Various security technologies, including AppSandbox and parental controls, depend on code signing.

In most cases, you can rely on Xcode automatic code signing, which requires only that you specify a codesigning identity in the build settings for your project. The steps to take are described in “Code Signing Your App”

in Tools Workflow Guide for Mac . If you need to incorporate code signing into an automated build system orif you link your app against third-party frameworks, refer to the procedures described in Code Signing Guide .

For a complete explanation of code signing in the context of App Sandbox, read “App Sandbox in Depth” in AppSandbox Design Guide .

Core OS FrameworksThe following technologies and frameworks are in the Core OS layer of Mac OS X:

Core OS LayerCore OS Frameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

67

Page 68: OSX Technology Overview

AccelerateYou can use the Accelerate framework (Accelerate.framework) to accelerate complex operations usingthe available vector unit and thereby improve performance. Hardware-based vector units boost the performanceof any app that exploits data parallelism, such as those that perform 3D graphic imaging, image processing,video processing, audio compression, and software-based cell telephony. (Quartz and QuickTime Kit incorporatevector capabilities, thus any app using these APIs can tap into this hardware acceleration without making anychanges.)

The Accelerate framework supports both the PowerPC AltiVec and Intel x86 SSE extensions internally butprovides a single interface for you to use in your app. The advantage of using this framework is that you cansimply write your code once without having to code different execution paths for each hardware platform.The functions of this framework are highly tuned for the specific platforms supported by Mac OS X and in manycases can offer better performance than hand-rolled code.

The Accelerate framework is an umbrella framework that wraps the vecLib and vImage frameworks into asingle package. The vecLib framework contains vector-optimized routines for doing digital signal processing,linear algebra, and other computationally expensive mathematical operations. The vImage framework supportsthe visual realm, adding routines for morphing, alpha-channel processing, and other image-buffer manipulations.

For information on how to use the components of the Accelerate framework, see vImage Programming Guide ,vImageReferenceCollection , andvecLibReference . Forgeneralperformance-related information, seePerformanceOverview .

Disk ArbitrationThe Disk Arbitration framework (DiskArbitration.framework) notifies your app when local and remotevolumes are mounted and unmounted. It also furnishes other updates on the status of remote and local mountsand returns information about mounted volumes. For example, if you provide the framework with the BSDdisk identifier of a volume, you can get the volume’s mount-point path.

For more information on Disk Arbitration, see Disk Arbitration Framework Reference .

OpenCLIntroduced in Mac OS X v10.6, the Open Computing Language (OpenCL) makes the high-performance parallelprocessing power of GPUs available for general-purpose computing. The OpenCL language is a general purposecomputer language, not specifically a graphics language, that abstracts out the lower-level details needed toperform parallel data computation tasks on GPUs and CPUs. Using OpenCL, you create compute kernels thatare then offloaded to a graphics card or CPU for processing. Multiple instances of a compute kernel can be runin parallel on one or more GPU or CPU cores, and you can link to your compute kernels from Cocoa, C, or C++apps.

Core OS LayerCore OS Frameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

68

Page 69: OSX Technology Overview

For tasks that involve data-parallel processing on large data sets, OpenCL can yield significant performancegains. There are many apps that are ideal for acceleration using OpenCL, such as signal processing, imagemanipulation, or finite element modeling. The OpenCL language has a rich vocabulary of vector and scalaroperators and the ability to operate on multidimensional arrays in parallel.

For information about OpenCL and how to write compute kernels, see OpenCL Programming Guide for MacOS X .

Open Directory (Directory Services)Open Directory is a directory services architecture that provides a centralized way to retrieve information storedin local or network databases. Directory services typically provide access to collected information about users,groups, computers, printers, and other information that exists in a networked environment (although they canalso store information about the local system). You use Open Directory in your programs to retrieve informationfrom these local or network databases. For example, if you’re writing an email program, you can use OpenDirectory to connect to a corporate LDAP server and retrieve the list of individual and group email addressesfor the company.

Open Directory uses a plug-in architecture to support a variety of retrieval protocols. Mac OS X provides plug-insto support LDAPv2, LDAPv3, NetInfo, AppleTalk, SLP, SMB, DNS, Microsoft Active Directory, and Bonjourprotocols, among others. You can also write your own plug-ins to support additional protocols.

The Directory Services framework (DirectoryServices.framework) publishes a programmatic interfacefor accessing Open Directory services.

For more information on this technology, see Open Directory Programming Guide . For information on how towrite Open Directory plug-ins, see Open Directory Plug-in Programming Guide .

System Configuration FrameworkSystem Configuration is a framework (SystemConfiguration.framework) through which apps can configurenetworks and determine if networks can be reached prior to connecting with them. With System Configuration,your app can determine and set configuration settings and respond dynamically to changes in that information.It can also determine if a remote host is reachable and, if it is, request a network connection so it can providecontent to its users. To assist in this, System Configuration does the following:

● It provides access to current network configuration information.

● It allows apps to determine the reachability of remote hosts and start PPP-based connections.

● It notifies apps when there are changes in network status and network configuration.

● It provides a flexible schema for defining and accessing stored preferences and the current networkconfiguration.

Core OS LayerCore OS Frameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

69

Page 70: OSX Technology Overview

To learn more about System Configuration, see System Configuration Programming Guidelines .

Core OS LayerCore OS Frameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

70

Page 71: OSX Technology Overview

This chapter summarizes the fundamental system technologies and facilities that are available to developersin Mac OS X. The lowest layer of Mac OS X comprises the kernel, drivers, and BSD portions of the system andis based primarily on open source technologies. Mac OS X extends this low-level environment with severalcore infrastructure technologies that make it easier for you to develop software.

If you are new to developing Mac OS X software, you should read through this chapter at least once tounderstand the available technologies and how you might use them in your software. Even experienceddevelopers should revisit this chapter periodically to remind themselves of the available technologies and lookfor recently introduced technologies.

High-Level FeaturesThe following are important features added to Mac OS X in recent major versions.

XPC Interprocess Communication and ServicesIntroduced in Mac OS X v10.7, XPC is a Mac OS X interprocess communication technology that complementsApp Sandbox by enabling privilege separation. Privilege separation, in turn, is a development strategy in whichyou divide an app into pieces according to the system resource access that each piece needs. The componentpieces that you create are called XPC services .

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

71

Kernel and Device Drivers Layer

Page 72: OSX Technology Overview

You create an XPC service as an individual target in your Xcode project. Each service gets its ownsandbox—specifically, it gets its own container and its own set of entitlements. In addition, an XPC servicethat you include with your app is accessible only by your app. These advantages add up to making XPC thebest technology for implementing privilege separation in a Mac OS X app.

XPC is integrated with “Grand Central Dispatch” (page 55) (GCD); when you create a connection, you associateit with a dispatch queue on which message traffic executes.

When the app is launched, the system automatically registers each XPC service it finds into the namespacevisible to the app. An app establishes a connection with one of its XPC services and sends it messages containingevents that the service then handles.

For more on XPC Services, read “Creating XPC Services” in Daemons and Services Programming Guide . To learnmore about App Sandbox, read App Sandbox Design Guide .

Caching APIIntroduced in Mac OS X v10.6, the libcache API is a low-level purgeable caching API. Aggressive caching isan important technique in maximizing application performance. However, when caching demands exceedavailable memory, the system must free up memory as necessary to handle new demands. Typically, this meanspaging cached data to and from relatively slow storage devices, sometimes even resulting in system-wideperformance degradation. Your application should avoid potential paging overhead by actively managing itsdata caches, releasing them as soon as it no longer needs the cached data.

In the wider system context, your application can now also help by creating caches that the operating systemcan simply purge on a priority basis as memory pressure necessitates. Mac OS X v10.6 and later includes thelibcache library and Foundation framework’s NSCache class to create these purgeable caches.

For more information about the functions of the libcache library, see libcache Reference . For more informationabout the NSCache class, see NSCache Class Reference .

In-Kernel Video CaptureI/O Video, introduced in Mac OS X v10.7, provides a kernel-level C++ programming interface for writing videocapture device drivers. I/O Video replaces the QuickTime sequence grabber API as a means of getting videointo Mac OS X.

I/O Video consists of the IOVideoDevice class on the kernel side (along with various related minor classes)that your driver should subclass, and a user space device interface for communicating with the driver.

For more information, see the IOVideoDevice.h header file in the Kernel framework.

Kernel and Device Drivers LayerHigh-Level Features

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

72

Page 73: OSX Technology Overview

The KernelBeneath the appealing, easy-to-use interface of Mac OS X is a rock-solid, UNIX-based foundation that isengineered for stability, reliability, and performance. The kernel environment is built on top of Mach 3.0 andprovides high-performance networking facilities and support for multiple, integrated file systems.

The following sections describe some of the key features of the kernel and driver portions of Darwin. Forpointers to more information about the kernel environment, see Getting Started with Darwin .

MachMach is at the heart of Darwin because it provides some of the most critical functions of the operating system.Much of what Mach provides is transparent to applications. It manages processor resources such as CPU usageand memory, handles scheduling, enforces memory protection, and implements a messaging-centeredinfrastructure for untyped interprocess communication, both local and remote. Mach provides many importantadvantages to Macintosh computing:

● Protected memory. The stability of an operating system should not depend on all executing applicationsbeing good citizens. Even a well-behaved process can accidentally write data into the address space ofthe system or another process, which can result in the loss or corruption of data or even precipitate systemcrashes. Mach ensures that an application cannot write in another application’s memory or in the operatingsystem’s memory. By walling off applications from each other and from system processes, Mach makes itvirtually impossible for a single poorly behaved application to damage the rest of the system. Best of all,if an application crashes as the result of its own misbehavior, the crash affects only that application andnot the rest of the system.

● Preemptive multitasking. With Mach, processes share the CPU efficiently. Mach watches over thecomputer’s processor, prioritizing tasks, making sure activity levels are at the maximum, and ensuring thatevery task gets the resources it needs. It uses certain criteria to decide how important a task is and thereforehow much time to allocate to it before giving another task its turn. Your process is not dependent onanother process yielding its processing time.

● Advanced virtual memory. In Mac OS X, virtual memory is “on” all the time. The Mach virtual memorysystem gives each process its own private virtual address space. For 32-bit applications, this virtual addressspace is 4 GB. For 64-bit applications, the theoretical maximum is approximately 18 exabytes, or 18 billionbillion bytes. Mach maintains address maps that control the translation of a task’s virtual addresses intophysical memory. Typically only a portion of the data or code contained in a task’s virtual address spaceresides in physical memory at any given time. As pages are needed, they are loaded into physical memoryfrom storage. Mach augments these semantics with the abstraction of memory objects. Named memoryobjects enable one task (at a sufficiently low level) to map a range of memory, unmap it, and send it toanother task. This capability is essential for implementing separate execution environments on the samesystem.

Kernel and Device Drivers LayerThe Kernel

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

73

Page 74: OSX Technology Overview

● Real-time support. This feature guarantees low-latency access to processor resources for time-sensitivemedia applications.

Mach also enables cooperative multitasking, preemptive threading, and cooperative threading.

64-Bit KernelMac OS X v10.6 and later contains a 64-bit kernel. Although Mac OS X allows a 32-bit kernel to run 64-bitapplications, a 64-bit kernel provides several benefits:

● The kernel can support large memory configurations more efficiently.

● The maximum size of the buffer cache is increased, potentially improving I/O performance.

● Performance is improved when working with specialized networking hardware that emulates memorymapping across a wire or with multiple video cards containing over 2 GB of video RAM.

Because a 64-bit kernel does not support 32-bit drivers and kernel extensions (KEXTs), those items must bebuilt for 64-bit. Fortunately, for most drivers and KEXTs, building for a 64-bit kernel is usually not as difficultas you might think. For the most part, transitioning a driver or KEXT to be 64-bit capable is just like transitioningany other piece of code. For details about how to make the transition, including what things to check for inyour code, see 64-Bit Transition Guide .

Device-Driver SupportDarwin offers an object-oriented framework for developing device drivers called the I/O Kit framework. Thisframework facilitates the creation of drivers for Mac OS X and provides much of the infrastructure that theyneed. It is written in a restricted subset of C++. Designed to support a range of device families, the I/O Kit isboth modular and extensible.

Device drivers created with the I/O Kit acquire several important features:

● True plug and play

● Dynamic device management (“hot plugging”)

● Power management (for both desktops and portables)

If your device conforms to standard specifications, such as those for mice, keyboards, audio input devices,modern MIDI devices, and so on, it should just work when you plug it in. If your device doesn’t conform to apublished standard, you can use the I/O Kit resources to create a custom driver to meet your needs. Devicessuch as AGP cards, PCI and PCIe cards, scanners, and printers usually require custom drivers or other supportsoftware in order to work with Mac OS X.

Kernel and Device Drivers LayerThe Kernel

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

74

Page 75: OSX Technology Overview

For information on creating device drivers, see I/O Kit Device Driver Design Guidelines .

Network Kernel ExtensionsDarwin offers kernel developers a technology for adding networking capabilities to the operating system:network kernel extensions (NKEs). The NKE facility allows you to create networking modules and even entireprotocol stacks that can be dynamically loaded into the kernel and unloaded from it. NKEs also make it possibleto configure protocol stacks automatically.

NKE modules have built-in capabilities for monitoring and modifying network traffic. At the data-link andnetwork layers, they can also receive notifications of asynchronous events from device drivers, such as whenthere is a change in the status of a network interface.

For information on how to write an NKE, see Network Kernel Extensions Programming Guide .

BSDIntegrated with Darwin is a customized version of the Berkeley Software Distribution (BSD) operating system(currently FreeBSD 5). Darwin’s implementation of BSD includes much of the POSIX API, which higher-levelapplications can also use to implement basic application features. BSD serves as the basis for the file systemsand networking facilities of Mac OS X. In addition, it provides several programming interfaces and services,including:

● The process model (process IDs, signals, and so on)

● Basic security policies such as file permissions and user and group IDs

● Threading support (POSIX threads)

● Networking support (BSD sockets)

Note For more information about the FreeBSD operating system, go to http://www.freebsd.org/.For more information about the boot process of Mac OS X, including how it launches the daemonsused to implement key BSD services, see Daemons and Services Programming Guide .

The following sections describe some of the key features of the BSD Layer of Mac OS X.

Kernel and Device Drivers LayerBSD

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

75

Page 76: OSX Technology Overview

IPC and Notification MechanismsMac OS X supports numerous technologies for interprocess communication (IPC) and for delivering notificationsacross the system. For more information about these technologies, see the cited technical document or therelevant man page.

● FSEvents. A mechanism for notifying your application when changes occur in the file system, such as atthe creation, modification, or removal of files and directories. The FSEvents API gives you a way to monitormany directories at once and detect general changes to a file hierarchy. However, it is not intended fordetecting fine-grained changes to individual files. For example, you might use this technology in backupsoftware to detect what files changed.

For information on how to use the FSEvents API, see File System Events Programming Guide .

● Kernel queues and kernel events.Mechanisms for intercepting kernel-level events to receive notificationsabout changes to sockets, processes, the file system, and other aspects of the system. Kernel queues andevents are part of the FreeBSD layer of the operating system and are described in the kqueue and keventman pages.

● BSD Notifications. Notification services similar to those offered by Core Foundation and Foundation, butwith some advantages over these. Your program can receive BSD notifications through mechanisms thatinclude Mach ports, signals, and file descriptors. Moreover, this technology is lightweight, efficient, andcapable of coalescing notifications.

You can add support for BSD notifications to any type of program, including Cocoa applications. For moreinformation, seeMacNotificationOverview or the notifyman page. See “Distributed Notifications” (page59) for a discussion of Cocoa and Core Foundation interfaces for interprocess notification.

● Sockets and ports. Portable mechanisms for interprocess communication. A socket represents one endof a communications channel between two processes either locally or across the network. A port is achannel between processes or threads on the local computer. Core Foundation and Foundation providehigher-level abstractions for ports and sockets that make them easier to implement and offer additionalfeatures. For example, you can use CFSocket with CFRunLoop to multiplex data received from a socketwith data received from other sources.

● Streams. A mechanism for transferring data between processes when you are communicating using anestablished transport mechanism such as Bonjour or HTTP. Higher-level interfaces of Core Foundation andFoundation (which work with CFNetwork) provide a stream-based way to read and write network dataand can be used with run loops to operate efficiently in a network environment.

● Pipes. A communications channel typically created between a parent and a child process when the childprocess is forked. Data written to a pipe is buffered and read in first-in, first-out (FIFO) order. You can createnamed pipes (pipe function) for communication between related processes or named pipes forcommunication between any two processes. A named pipe must be created with a unique name knownto both the sending and the receiving process.

Kernel and Device Drivers LayerBSD

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

76

Page 77: OSX Technology Overview

● Shared memory. A region of memory that has been allocated by a process specifically for the purpose ofbeing readable and possibly writable among several processes. You can create regions of shared memoryusing several BSD approaches, including the shm_open and shm_unlink routines, and the mmap routine.Access to shared memory is controlled through POSIX semaphores, which implement a kind of lockingmechanism.

Although shared memory permits any process with the appropriate permissions to read or write a sharedmemory region directly, it is very fragile—leading to the dangers of data corruption and securitybreaches—and should be used with care. It is best used only as a repository for raw data (such as pixelsor audio), with the controlling data structures accessed through more conventional interprocesscommunication.

For information about shm_open, shm_unlink, and mmap, see the shm_open, shm_unlink, and mmapman pages.

● Apple event. A high-level semantic event that an application can send to itself, to other applications onthe same computer, or to applications on a remote computer. Applications can use Apple events to requestservices and information from other applications. To supply services, you define objects in your applicationthat can be accessed using Apple events and then provide Apple event handlers to respond to requestsfor those objects.

Although Apple events are not a BSD technology, they are a low-level alternative for interprocesscommunication. For information on how to use Apple events, see Apple Events Programming Guide .

Note Mach ports are another technology for transferring messages between processes. However,messaging with Mach port objects is the least desirable way to communicate between processes.Mach port messaging relies on knowledge of the kernel interfaces, which may change in a futureversion of Mac OS X. The only time you might consider using Mach ports directly is if you are writingsoftware that runs in the kernel.

Network SupportMac OS X is one of the premier platforms for computing in an interconnected world. It supports the dominantmedia types, protocols, and services in the industry as well as differentiated and innovative services from Apple.

The Mac OS X network protocol stack is based on BSD. The extensible architecture provided by network kernelextensions, summarized in “Network Kernel Extensions” (page 75), facilitates the creation of modulesimplementing new or existing protocols that can be added to this stack.

Standard Network ProtocolsMac OS X provides built-in support for a large number of network protocols that are standard in the computingindustry. Table 6-1 summarizes these protocols.

Kernel and Device Drivers LayerBSD

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

77

Page 78: OSX Technology Overview

Table 6-1 Network protocols

DescriptionProtocol

802.1x is a protocol for implementing port-based network access over wired orwireless LANs. It supports a wide range of authentication methods, including TLS,TTLS, LEAP, MDS, and PEAP (MSCHAPv2, MD5, GTC).

802.1x

The Dynamic Host Configuration Protocol and the Bootstrap Protocol automatethe assignment of IP addresses in a particular network.

DHCP andBOOTP

Domain Name Services is the standard Internet service for mapping host names toIP addresses.

DNS

The File Transfer Protocol and Secure File Transfer Protocol are two standard meansof moving files between computers on TCP/IP networks.

FTP and SFTP

The Hypertext Transport Protocol is the standard protocol for transferring webpagesbetween a web server and browser. Mac OS X provides support for both the insecureand secure versions of the protocol.

HTTP and HTTPS

The Lightweight Directory Access Protocol lets users locate groups, individuals, andresources such as files and devices in a network, whether on the Internet or on acorporate intranet.

LDAP

The Name Binding Protocol is used to bind processes across a network.NBP

The Network Time Protocol is used for synchronizing client clocks.NTP

The Printer Access Protocol is used for spooling print jobs and printing to networkprinters.

PAP

For dial-up (modem) access, Mac OS X includes PPP (Point-to-Point Protocol). PPPsupport includes TCP/IP as well as the PAP and CHAP authentication protocols.

PPP

The Point-to-Point Protocol over Ethernet protocol provides an Ethernet-baseddial-up connection for broadband users.

PPPoE

The Secure MIME protocol supports encryption of email and the attachment ofdigital signatures to validate email addresses.

S/MIME

Service Location Protocol is designed for the automatic discovery of resources(servers, fax machines, and so on) on an IP network.

SLP

The Simple Object Access Protocol is a lightweight protocol for exchangingencapsulated messages over the web or other networks.

SOAP

The Secure Shell protocol is a safe way to perform a remote login to anothercomputer. Session information is encrypted to prevent unauthorized access of data.

SSH

Kernel and Device Drivers LayerBSD

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

78

Page 79: OSX Technology Overview

DescriptionProtocol

Mac OS X provides two transmission-layer protocols, TCP (Transmission ControlProtocol) and UDP (User Datagram Protocol), to work with the network-layer InternetProtocol (IP). (Mac OS X includes support for IPv6 and IPSec.)

TCP/IP andUDP/IP

XML-RPC is a protocol for sending remote procedure calls using XML over the web.XML-RPC

Apple also implements a number of file-sharing protocols; see Table 6-4 (page 82) for a summary of theseprotocols.

Network TechnologiesMac OS X supports the network technologies listed in Table 6-2.

Table 6-2 Network technology support

DescriptionTechnology

For the Ethernet ports built into every new Macintosh.Ethernet 10/100Base-T

Also known as Gigabit Ethernet. For data transmission over fiber-optic cableand standardized copper wiring.

Ethernet 1000Base-T

This Ethernet format uses 9 KB frames for interserver links rather than thestandard 1.5 KB frame. Jumbo Frame decreases network overhead andincreases the flow of server-to-server and server-to-application data.

Jumbo Frame

Supports modem and ISDN capabilities.Serial

Supports the 802.11b, 802.11g, and 802.11n wireless network technologiesusing AirPort and AirPort Extreme.

Wireless

IP routing provides routing services for small networks. It uses RoutingInformation Protocol (RIP) in its implementation.

IP Routing/RIP

Enables a computer host to be physically connected to multiple data linksthat can be on the same or different networks.

Multihoming

Allows a network administrator to assign multiple IP addresses to a singlenetwork interface.

IP aliasing

See “Bonjour” (page 56).Zero-configurationnetworking

Kernel and Device Drivers LayerBSD

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

79

Page 80: OSX Technology Overview

DescriptionTechnology

Allows computers to share a single System folder, which is installed on acentralized server that the system administrator controls. Users store theirdata in home directories on the server and have access to a commonApplications folder, both of which are also commonly installed on the server.

NetBoot

Allows users to share information with other users on an intranet, no matterwhat type of computer or browser they are using. The Apache web serveris integrated as the system’s HTTP service.

Personal web sharing

Network DiagnosticsNetwork diagnostics is a way of helping the user solve network problems. Although modern networks aregenerally reliable, there are still times when network services may fail. Sometimes the cause of the failure isbeyond the ability of the desktop user to fix, but sometimes the problem is in the way the user’s computer isconfigured. The network diagnostics feature provides a diagnostic application to help the user locate problemsand correct them.

If your application encounters a network error, you can use the diagnostic interfaces of CFNetwork to launchthe diagnostic application and attempt to solve the problem interactively. You can also choose to reportdiagnostic problems to the user without attempting to solve them.

For more information on using this feature, see the header files of CFNetwork.

File-System SupportThe file-system component of Darwin is based on extensions to BSD and an enhanced Virtual File System (VFS)design. The file-system component includes the following features:

● Permissions on removable media. This feature is based on a globally unique ID registered for each connectedremovable device (including USB and FireWire devices) in the system.

● Access control lists

● URL-based volume mounts, which enable users (via a Finder command) to mount such things as AppleShareand web servers

● Unified buffer cache, which consolidates the buffer cache with the virtual-memory cache

● Long filenames (255 characters or 755 bytes, based on UTF-8)

● Support for hiding filename extensions on a per-file basis

● Journaling of all file-system types to aid in data recovery after a crash

Kernel and Device Drivers LayerBSD

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

80

Page 81: OSX Technology Overview

Because of its multiple application environments and the various kinds of devices it supports, Mac OS X handlesfile data in many standard volume formats. Table 6-3 lists the supported formats.

Table 6-3 Supported local volume formats

DescriptionVolume format

Also called HFS (hierarchical file system) Plus, or HFS+. This is the default root andbooting volume format in Mac OS X. This extended version of HFS optimizes thestorage capacity of large hard disks by decreasing the minimum size of a singlefile.

Mac OSExtendedFormat

Also called hierarchical file system, or HFS. This is the legacy volume format in MacOS systems prior to Mac OS 8.1. HFS (like HFS+) stores resources and data in separateforks of a file and makes use of various file attributes, including type and creatorcodes.

Mac OSStandard Format

Universal Disk Format, used for hard drives and optical disks, including most typesof CDs and DVDs. Mac OS X supports reading UDF revisions 1.02 through 2.60 onboth block devices and most optical media, and it supports writing to block devicesand to DVD-RW and DVD+RW media using UDF 2.00 through 2.50 (except formirrored metadata partitions in 2.50). You can find the UDF specification athttp://www.osta.org.

UDF

The standard format for CD-ROM volumes.ISO 9660

The NT File System, used by Windows computers. Mac OS X can readNTFS-formatted volumes but cannot write to them.

NTFS

UNIX File System, a flat (that is, single-fork) disk volume format, based on the BSDFFS (Fast File System), that is similar to the standard volume format of most UNIXoperating systems; it supports POSIX file-system semantics, which are importantfor many server applications. Although UFS is supported in Mac OS X, its use isdiscouraged.

UFS

Mac OS X supports the FAT file systems used by many Windows computers. It canread and write FAT-formatted volumes.

MS-DOS (FAT)

HFS+ volumes support aliases, symbolic links, and hard links, whereas UFS volumes support symbolic links andhard links but not aliases. Although an alias and a symbolic link are both lightweight references to a file ordirectory elsewhere in the file system, they are semantically different in significant ways. For more information,see “Aliases and Symbolic Links” in File System Overview .

Kernel and Device Drivers LayerBSD

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

81

Page 82: OSX Technology Overview

Note Mac OS X does not support stacking in its file-system design.

Because Mac OS X is intended to be deployed in heterogeneous networks, it also supports several networkfile-sharing protocols. Table 6-4 lists these protocols.

Table 6-4 Supported network file-sharing protocols

DescriptionFile protocol

Apple Filing Protocol, the principal file-sharing protocol in Mac OS 9 systems (availableonly over TCP/IP transport).

AFP client

Network File System, the dominant file-sharing protocol in the UNIX world.NFS client

Web-based Distributed Authoring and Versioning, an HTTP extension that allowscollaborative file management on the web.

WebDAV

SMB/CIFS, a file-sharing protocol used on Windows and UNIX systems.SMB/CIFS

SecurityThe roots of Mac OS X in the UNIX operating system provide a robust and secure computing environmentwhose track record extends back many decades. Mac OS X security services are built on top of BSD (BerkeleySoftware Distribution), an open-source standard. BSD is a form of the UNIX operating system that providesbasic security for fundamental services, such as file and network access.

The CommonCrypto library, introduced in Mac OS X v10.7 to libSystem, provides raw cryptographic algorithms.It is intended to replace similar OpenSSL interfaces.

Note Beginning in Mac OS X v10.7, CDSA (Common Data Security Architecture) and OpenSSL havebeen deprecated and their further use is discouraged. The Security Transforms technology is apossible replacement for CDSA and CommonCrypto is the possible replacement for OpenSSL. SecurityTransforms, which are part of the Security framework, are described in “Security Services” (page 56).

Mac OS X also includes the following security features:

● Adoption of the Mandatory Access Control (MAC) framework, which provides a fine-grained securityarchitecture for controlling the execution of processes at the kernel level. This feature enables the“sandboxing” of applications, which lets you limit the access of a given application to only those featuresyou designate.

Kernel and Device Drivers LayerBSD

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

82

Page 83: OSX Technology Overview

● Support for code signing and installer package signing. This feature lets the system validate applicationsusing a digital signature and warn the user if an application is tampered with.

● Compiler support for fortifying your source code against potential security threats. This support includesoptions to disallow the execution of code located on the stack or other portions of memory containingdata. It also includes some new GCC compiler warnings.

● Support for putting unknown files into quarantine. This is especially useful for developers of web browsersor other network-based applications that receive files from unknown sources. The system prevents accessto quarantined files unless the user explicitly approves that access.

For an introduction to Mac OS X security features, see Security Overview .

Scripting SupportDarwin includes all of the scripting languages commonly found in UNIX-based operating systems. In additionto the scripting languages associated with command-line shells (such as bash and csh), Darwin also includessupport for Perl, Python, Ruby, Ruby on Rails, and others.

Mac OS X provides scripting bridges to the Objective-C classes of Cocoa. These bridges let you use Cocoaclasses from within your Python and Ruby scripts. For information about using these bridges, see Ruby andPython Programming Topics for Mac .

Threading SupportMac OS X provides full support for creating multiple preemptive threads of execution inside a single process.Threads let your program perform multiple tasks in parallel. For example, you might create a thread to performsome lengthy calculations in the background while a separate thread responds to user events and updatesthe windows in your application. Using multiple threads can often lead to significant performance improvementsin your application, especially on computers with multiple CPU cores. Multithreaded programming is notwithout its dangers though. It requires careful coordination to ensure your application’s state does not getcorrupted.

All user-level threads in Mac OS X are based on POSIX threads (also known as pthreads). A pthread is alightweight wrapper around a Mach thread, which is the kernel implementation of a thread. You can use thepthreads API directly or use any of the threading packages offered by Cocoa. Each threading package offers adifferent combination of flexibility versus ease-of-use. All offer roughly the same performance, however.

In general, you should try to use Grand Central Dispatch or operation objects to perform work concurrently.However, there may still be situations where you need to create threads explicitly. For more information aboutthreading support and guidelines on how to use threads safely, see Threading Programming Guide .

Kernel and Device Drivers LayerBSD

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

83

Page 84: OSX Technology Overview

X11The X11 windowing system is provided as an optional installation component for the system. This windowingsystem is used by many UNIX applications to draw windows, controls, and other elements of graphical userinterfaces. The Mac OS X implementation of X11 uses the Quartz drawing environment to give X11 windowsa native Mac OS X feel. This integration also makes it possible to display X11 windows alongside windows fromnative applications written in Cocoa.

Software Development SupportThe following sections describe some additional features of Mac OS X that affect the software developmentprocess.

Binary File ArchitectureThe underlying architecture of Mac OS X executables was built from the beginning with flexibility in mind. Thisflexibility has become important as Macintosh computers have transitioned from using PowerPC to Intel CPUsand from supporting only 32-bit applications to 64-bit applications. The following sections provide an overviewof the types of architectures you can support in your Mac OS X executables along with other information aboutthe runtime and debugging environments available to you.

Hardware Architectures

When Mac OS X was first introduced, it was built to support a 32-bit PowerPC hardware architecture. WithApple’s transition to Intel-based Macintosh computers, Mac OS X added initial support for 32-bit Intel hardwarearchitectures. In addition to 32-bit support, Mac OS X v10.4 added some basic support for 64-bit architecturesas well and this support was expanded in Mac OS X v10.5. This means that applications and libraries can nowsupport four different architectures:

● 32-bit Intel (i386)

● 32-bit PowerPC (ppc)

● 64-bit Intel (x86_64)

● 64-bit PowerPC (ppc64)

Although applications can support all of these architectures in a single binary, doing so is not required. Thatdoes not mean application developers can pick a single architecture and use that alone, however. It isrecommended that developers create their applications as “universal binaries” so that they run natively onboth 32-bit Intel and PowerPC processors. If performance or development need warrants it, you might alsoadd support for the 64-bit versions of each architecture.

Kernel and Device Drivers LayerBSD

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

84

Page 85: OSX Technology Overview

Because libraries can be linked into multiple applications, you might consider supporting all of the availablearchitectures when creating a library. Although supporting all architectures is not required, it does givedevelopers using your library more flexibility in how they create their applications, and it is recommended.

Supporting multiple architectures requires careful planning and testing of your code for each architecture.There are subtle differences from one architecture to the next that can cause problems if not accounted for inyour code. For example, the PowerPC and Intel architectures use different endian structures for multibyte data.In addition, some built-in data types have different sizes in 32-bit and 64-bit architectures. Accounting forthese differences is not difficult but requires consideration to avoid coding errors.

Xcode provides integral support for creating applications that support multiple hardware architectures. Forinformation about tools support and creating universal binaries to support both PowerPC and Intel architectures,see Universal Binary Programming Guidelines, Second Edition . For information about 64-bit support in Mac OSX, including links to documentation for how to make the transition, see “64-Bit Support” (page 85).

64-Bit Support

Mac OS X was initially designed to support binary files on computers using a 32-bit architecture. In Mac OS Xv10.4, however, support was introduced for compiling, linking, and debugging binaries on a 64-bit architecture.This initial support was limited to code written using C or C++ only. In addition, 64-bit binaries could linkagainst the Accelerate framework and libSystem.dylib only.

Starting in Mac OS X v10.5, most system libraries and frameworks are 64-bit ready, meaning they can be usedin both 32-bit and 64-bit applications. Frameworks built for 64-bit means you can create applications thataddress extremely large data sets, up to 128 TB on the current Intel-based CPUs. On Intel-based Macintoshcomputers, some 64-bit applications may even run faster than their 32-bit equivalents because of the availabilityof extra processor resources in 64-bit mode.

There are a few technologies that have not been ported to 64-bit. Development of 32-bit applications withthese APIs is still supported, but if you want to create a 64-bit application, you must use alternative technologies.Among these APIs are the following:

● The entire QuickTime C API (not deprecated, but developers should use QuickTime Kit instead in 64-bitapplications)

● HIToolbox, Window Manager, and most other Carbon user interface APIs (not deprecated, but developersshould use Cocoa user interface classes and other alternatives); see 64-Bit Guide for Carbon Developers forthe list of specific APIs and transition paths.

Mac OS X uses the LP64 model that is in use by other 64-bit UNIX systems, which means fewer headacheswhen porting from other operating systems. For general information on the LP64 model and how to write64-bit applications, see 64-Bit Transition Guide . For Cocoa-specific transition information, see 64-Bit TransitionGuide for Cocoa .

Kernel and Device Drivers LayerBSD

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

85

Page 86: OSX Technology Overview

Object File Formats

Mac OS X is capable of loading object files that use several different object-file formats. Mach-O format is theformat used for all native Mac OS X application development.

For information about the Mach-O file format, see Mac OS X ABI Mach-O File Format Reference . For additionalinformation about using Mach-O files, see Mach-O Programming Topics .

Debug File Formats

Whenever you debug an executable file, the debugger uses symbol information generated by the compilerto associate user-readable names with the procedure and data address it finds in memory. Normally, thisuser-readable information is not needed by a running program and is stripped out (or never generated) bythe compiler to save space in the resulting binary file. For debugging, however, this information is very importantto be able to understand what the program is doing.

Mac OS X supports two different debug file formats for compiled executables: stabs and DWARF. The stabsformat is present in all versions of Mac OS X and until the introduction of Xcode 2.4 was the default debuggingformat. Code compiled with Xcode 2.4 and later uses the DWARF debugging format by default. When usingthe stabs format, debugging symbols, like other symbols are stored in the symbol table of the executable; seeMac OS X ABI Mach-O File Format Reference . With the DWARF format, however, debugging symbols are storedeither in a specialized segment of the executable or in a separate debug-information file.

For information about the DWARF standard, go to http://www.dwarfstd.org. For information about the stabsdebug file format, see STABS Debug Format . For additional information about Mach-O files and their storedsymbols, see Mach-O Programming Topics .

Runtime Environments

Since its first release, Mac OS X has supported several different environments for running applications. Themost prominent of these environments is the dynamic link editor (dyld) environment, which is also the onlyenvironment supported for active development. Most of the other environments provided legacy supportduring the transition from Mac OS 9 to Mac OS X and are no longer supported for active development. Thefollowing sections describe the runtime environments you may encounter in various versions of Mac OS X.

Dyld Runtime Environment

The dyld runtime environment is the native environment in Mac OS X and is used to load, link, and executeMach-O files. At the heart of this environment is the dyld dynamic loader program, which handles the loadingof a program’s code modules and associated dynamic libraries, resolves any dependencies between thoselibraries and modules, and begins the execution of the program.

Kernel and Device Drivers LayerBSD

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

86

Page 87: OSX Technology Overview

Upon loading a program’s code modules, the dynamic loader performs the minimal amount of symbol bindingneeded to launch your program and get it running. This binding process involves resolving links to externallibraries and loading them as their symbols are used. The dynamic loader takes a lazy approach to bindingindividual symbols, doing so only as they are used by your code. Symbols in your code can be strongly-linkedor weakly-linked. Strongly-linked symbols cause the dynamic loader to terminate your program if the librarycontaining the symbol cannot be found or the symbol is not present in the library. Weakly-linked symbolsterminate your program only if the symbol is not present and an attempt is made to use it.

For more information about the dynamic loader program, see the dyld man page. For information aboutbuilding and working with Mach-O executable files, see Mach-O Programming Topics .

Language SupportThe tools that come with Mac OS X provide direct support for developing software using the C, C++, Objective-C,and Objective-C++, languages along with numerous scripting languages. Support for other languages mayalso be provided by third-party developers.

The following sections call out key features in some of these environments.

Objective-C

Objective-C is a C-based programming language with object-oriented extensions. It is also the primarydevelopment language for Cocoa applications. Unlike C++ and some other object-oriented languages,Objective-C comes with its own dynamic runtime environment. This runtime environment makes it much easierto extend the behavior of code at runtime without having access to the original source.

Objective-C 2.0 supports the following features:

● Object properties, which offer an alternative way to declare member variables

● Support for garbage collection; see Garbage Collection Programming Guide

● A for operator syntax for performing fast enumerations of collections

● Protocol enhancements

● Deprecation syntax

In Mac OS X v10.6, support was added for blocks, which are described in “Blocks” (page 55).

For information about the Objective-C language, see The Objective-C Programming Language .

Kernel and Device Drivers LayerBSD

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

87

Page 88: OSX Technology Overview

If you are a developer of iOS applications, many of the frameworks available in Mac OS X should already seemfamiliar to you. The basic technology stack in iOS is identical in many respects to the one in Mac OS X. Despitethe similarities, however, not all of the frameworks in Mac OS X are exactly the same as their iOS counterparts.This chapter describes the differences you may encounter as you create Mac OS X applications and explainshow you can adjust your code to some of the more significant differences.

Note This chapter is intended for developers who are already familiar with Cocoa terminology andprogramming techniques. If you want to learn more about the basic design patterns used for Cocoaapplications (and Cocoa Touch applications), see Cocoa Fundamentals Guide .

General Migration NotesIn Mac OS X, applications typically have a screen that is larger, and resources that are greater, than in iOS. Youalso have more frameworks at your disposal in Mac OS X development and (generally) more programmaticpossibilities. This greater range of possibilities may be a pleasant prospect, but it does require different waysof thinking about user expectations and application design.

If your Cocoa Touch application has already been factored according to the Model-View-Controller designpattern, it should be relatively easy to migrate key portions of your application to Mac OS X.

Migrating Your Data ModelCocoa Touch applications whose data model is based on classes in the Foundation and Core Foundationframeworks can be brought over to Mac OS X with little or no modification. Mac OS X includes both frameworks,and they are virtually identical to their iOS counterparts. Most of the differences that do exist are relativelyminor or are related to features that are not present in iOS. For example, iOS applications do not supportAppleScript. For a detailed list of differences, see “Foundation Framework Differences” (page 100).

If your Cocoa Touch application is built on top of Core Data, you can easily migrate that data model to a MacOS X application. The Core Data framework in Mac OS X supports binary and SQLite data stores (as it does iniOS), but it also supports XML data stores. For the supported data stores, you can copy your Core Data resourcefiles to your Mac OS X application project and use them as is. For information on how to use Core Data in yourXcode projects, see Core Data Programming Guide .

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

88

Migrating from Cocoa Touch

Page 89: OSX Technology Overview

Mac OS X applications can display much more data on the screen than iOS applications can, you can expandyour data model as part of your migration, if that makes sense. Although, users of both platforms typicallywant to see the most important information in the least amount of time, desktop users have the option ofviewing application data in several windows at once. In addition to having a larger form factor, a Mac OS Xsystem gives an application access to more resources, including memory. Although you can work with largerdata sets, you still have to be cognizant of application performance in Mac OS X and ensure that your algorithmsscale to the new platform.

Migrating Your User InterfaceThe structure and implementation of the user interface in a Mac OS X application is very different from thatof an iOS application. Adapting your application to these differences is the main work of migration. “DifferencesBetween the UIKit and AppKit Frameworks” (page 92) discusses the differences in some detail, but there aresome general themes that are interesting if you are migrating your applications from iOS to Mac OS X.

● Physical differences. You are coming from an embedded operating system for mobile devices to a laptopor desktop system where applications have much greater screen real estate, a more dependable supplyof power, and a much larger pool of memory to draw upon. These physical differences play a role in howan application presents information to users and in how users interact with your application.

Take, for example, windows and the objects that represent them in Cocoa and Cocoa Touch. There is onlyone window per application in iOS; that window has a fixed size, plays a limited role in the user interface,and cannot be manipulated by users. On the other hand, a Mac OS X application can (and often does)have multiple windows. These windows can be for individual documents, or they can be secondary windowsfor such purposes as tool palettes and application preferences. Users can move, resize, close, minimize,and perform other operations with windows. Because you can have windows of virtually any number andsize, you can present related information at the same time instead of (as in iOS) breaking it into chunksand deciding what order to present those chunks.

● Mode of interaction. The way users interact with the device or computer influences characteristics of theuser interface. A mobile device has a smaller screen than that of a desktop system. And because it is meantto be mobile, it shouldn’t be encumbered by requiring input devices other than the human finger. Themodel for user input is thus direct manipulation by touching objects on the screen with one or morefingers. However, the finger is a less-than-precise pointer, and so views must be large enough to be targetsof touches.

In Mac OS X, the entity that is analogous to the finger is the mouse. Because the mouse pointer is smallerthan a finger, it is capable of more precise targeting. As a result, many views are smaller in Mac OS X thanin iOS. In addition, a mouse is not simply a pointing instrument; it has buttons and is therefore capable ofmultiple forms of input related to the same target. Not only can you click a view with a mouse pointerbut, by hovering the mouse over a view, you might be able to get other responses—for example, tooltips.

Migrating from Cocoa TouchGeneral Migration Notes

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

89

Page 90: OSX Technology Overview

● File system. The file system of iOS is opaque compared to the file system of Mac OS X. Because users ofan iOS application have no direct access to the file system, they cannot choose where to put or find files;an application reads and writes all files itself to prescribed locations in its sandbox. In contrast, the userin Mac OS X often tells applications—particularly document-based applications—where to get the filesto read and where to save files. Thus many applications in Mac OS X must be prepared to handle documentsand other files that users select, and this preparation can entail issues related to document format, fileencoding, and so on. However, not all Mac OS X applications do this; some applications (for example,iPhoto and iTunes) keep their databases in a well-known location and provide ways to find files automaticallywithout a user’s intervention.

For general information about the user interface design principles of Mac OS X, see OS X Human InterfaceGuidelines . For additional information about the windows and views you use to build your interface, and theunderlying architecture on which they are built, see Mac App Programming Guide .

Migrating Your Controller LayerController objects are a critical area of difference between application development for iOS and for Mac OS X.In iOS, view controllers are key components of the application models for traversing screens of information,for presenting data modally, and for handling device-specific behavior such as orientation changes. AlthoughMac OS X also provides view controllers, they play a much reduced role in application design. AppKit has theNSViewController class, which by name would seem to be like the UIViewController class of the UIKitframework, but the former class lacks all of the capabilities of UIViewController except for view loading.AppKit also offers the NSWindowController class, which is conceptually closer to UIViewController.Window controllers are used to manage a window and its current contents. They are a component of thearchitecture for document-based applications, but you can (and should) use window controllers apart fromthat architecture to manage a window and its views.

Mac OS X doesn’t have some view-controller idioms that you are used to in iOS. For example, it has nothingequivalent to a navigation controller that manages a stack of view controllers. In situations like these, youshould consider reworking your user interface to take advantage of the larger screen size and multiple windowsthat are available in Mac OS X.

Mac OS X does have the NSController class and its concrete subclasses. Instances of these classes arecontroller objects used in the Cocoa bindings technology. Their primary purpose is to manage an application’sdata model rather than to manage views, and thus can be considered data controllers rather than viewcontrollers. Cocoa bindings enable you, during development, to establish a connection (or binding) betweenan item of data stored in a model object and the presentation of that data in a view. Any change of value oneither side of that connection is propagated to the other side. Cocoa bindings, a technology that is not availablein iOS, can be a valuable asset in the development process.

Migrating from Cocoa TouchGeneral Migration Notes

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

90

Page 91: OSX Technology Overview

For information about view controllers in Mac OS X, see NSViewController Class Reference and for informationabout window controllers see NSWindowController Class Reference . To learn more about NSControllerobjects and Cocoa bindings, see Cocoa Bindings Programming Topics .

Application TypesWhen you create an iOS application project in Xcode, you are presented with a list of application templates:navigation-based, tab bar, split view-based, utility, and so on. This variety of templates reflects the fact thatthere is a set of predefined iOS application types for you to choose from. However, when you create a Mac OSX application project, there are only two application types to choose from (disregarding for the moment theapplication templates Cocoa-AppleScript and Quartz Composer):

● A single-window application

● A document-based application (see “Documents” (page 94) for more about these kinds of applications)

Either one of these types of applications can have one or more secondary windows. And either type of applicationcan use Core Data for storage; if an application project uses Core Data, you can also include in it a Spotlightimporter plug-in.

Because Mac OS X has few predefined application types, you have a lot of freedom to define how your applicationlooks and behaves. Keep in mind, though, that your application should conform to the guidelines spelled outin OS X Human Interface Guidelines .

Migration GuidelinesHere are a few suggestions to guide you when migrating your application to Mac OS X:

● Stick with the idioms and metaphors that are native to the platform. Don’t try to impose the idioms of iOSon a Mac OS X application—for example, don’t try to implement a stack of view controllers. Keep with thestrengths of the platform you’re developing for.

● Focus the user on the task he or she is doing at any time. How you do this should be informed by thecapabilities and physical realities of Mac OS X, such as multiple windows and more screen space to operatein.

● Once you get the basic part of your application working, start thinking about the other features you canadd to your application to flesh it out. These might include such as user preferences, printing, andundo-redo. Many of these ancillary features exist in iOS; however, the programmatic interfaces andtechniques for implementing them are very different.

Migrating from Cocoa TouchGeneral Migration Notes

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

91

Page 92: OSX Technology Overview

Differences Between the UIKit and AppKit FrameworksIn Mac OS X, the AppKit framework provides the infrastructure for building graphical applications, managingthe event loop, and performing other interface-related tasks. The AppKit framework is distinct from thecorresponding iOS framework, UIKit. Therefore, when migrating an iOS application to Mac OS X, you mustreplace a significant number of interface-related classes and code related to those classes.

For information about the classes of AppKit, see Application Kit Framework Reference .

User Events and Event HandlingHandling events in Mac OS X differs significantly from handling events in iOS applications, mainly because thetypes of user events for each platform differ. If your application does its own event handling, you will have torewrite much if not all of the event-handling code.

Whereas iOS has only touch events and motion events, Mac OS X has mouse events, keyboard events, trackpadevents, tablet events, and tracking-area events. All of these event types relate to specific peripheral devicesattached to a computer system. In addition, most of these event types have phases (for example, key-up andmouse-down ) or modifiers (for example, pressing the Control key and a character key simultaneously) thatevent-handling code often has to test for.

Although the AppKit framework defines touch objects (NSTouch) and gesture events, these events areappropriate only for laptops or desktop computers with supported trackpads. If your iOS application handlestouches or gestures, its Mac OS X counterpart has to provide an alternative means (for example, menu itemsor controls) for users to indicate their intentions. The trackpad should not be the sole means for users to interactwith your application.

The basic techniques for handling events in each platform are similar. A custom view must opt in to handleevents, and, to handle the event, it must implement one or more methods declared by the responder class ofthe application framework. You can do some event-handling tasks in Mac OS X applications that have noparallel in iOS applications, such as tracking the movement of the mouse pointer and monitoring incomingevents in your own application or another application.

For more information about handling events in Mac OS X applications, see Cocoa Event Handling Guide .

WindowsAt a basic level, windows in AppKit play the same role they do in UIKit. They present graphical content in arectangular area of the screen, they are at the root of a view hierarchy, they coordinate drawing operations,and they help to distribute events. In every other respect, windows and the framework objects that representthem in Mac OS X and in iOS are different. Windows in AppKit are more complex and multifaceted than theirUIKit counterparts. There are key differences in these aspects of an application:

Migrating from Cocoa TouchDifferences Between the UIKit and AppKit Frameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

92

Page 93: OSX Technology Overview

● Visible characteristics of windows. Most iOS applications have only one window fixed to the size of thescreen (minus the status bar). In contrast, a Mac OS X application can have any number of windows, andthose windows share the screen space with other applications’ windows. Windows can be of any size andhave distinct styles. Whereas an iOS window has no visual adornments, a Mac OS X window usually has atitle, may have a toolbar, and can have controls for moving, closing, resizing, and minimizing the window.

● Main and secondary windows. An application in Mac OS X can have one or more main or secondarywindows. A main window is the principal focus of user events and presents an application’s data. Asecondary window serves an auxiliary function such as the specification of a color for an attribute; itprovides additional control over the data presented in the main window. Secondary windows are oftenpanels—instances of the NSPanel class. If an application has more than one main window, it is typicallya document-based application, with each main window containing a separate document.

A secondary window can have a special status of being key . A key window is the current focus of keyboardevents.

● Inheritance and windows. In UIKit, the UIWindow class is a subclass of UIView, but in AppKit, theNSWindow class is a subclass of NSResponder. Consequently, windows in AppKit are not backed by CoreAnimation layers as they are in UIKit. That fact does not prevent you from using Core Animation in windows;you just have to do animation explicitly, at the view level.) See Table 7-2 (page 99) for a summary of CoreAnimation differences.

MenusNearly all applications written for Mac OS X have a much larger command set than do comparable iOSapplications. Mac OS X applications consequently have menu bars, and iOS applications put the commandsthey do have in such user interface elements as toolbars, buttons, table views, switches, and editing-menuitems. Consequently, when migrating your application to iOS, consider moving the commands invoked bythese objects into menus or duplicating them as menu items.

You should become familiar with the conventions and behavior of menus in Mac OS X. An application’s menubar has standard menus: the Apple menu, the application menu, File, Edit, and so on. Each of these menus hasstandard menu items. When you create a Mac OS X application project in Xcode, the nib-file template providesyou with a “starter set” of menus for your application menu bar; remove and add menus and menu items fromthe set as appropriate to your application.

Menu items use the target-action model to send commands (that is, action messages) to appropriate objectsin the application. Some of the template menu items prewire their target and action properties. You can assignkey equivalents to menu items that are most frequently invoked.

Mac OS X applications can have pop-up lists, contextual menus, and menu-like controls such as the combobox in addition to menus in the menu bar.

To learn more about menus, read Application Menu and Pop-up List Programming Topics .

Migrating from Cocoa TouchDifferences Between the UIKit and AppKit Frameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

93

Page 94: OSX Technology Overview

DocumentsA document-based application is one that enables users to create, edit, save , and open multiple documents.Two examples of document-based applications are word-processing and spreadsheet applications. AlthoughiOS applications can be document based (Pages and Numbers, for example), UIKit does not provide a formalarchitecture for this purpose. This lack of an architecture is understandable because a simpler content modelis appropriate for most iOS applications.

Mac OS X has an architecture for document-based applications because this content model is common for theplatform. This architecture is closely based on the Model-View-Controller design pattern. Each document hasits own main window and can have secondary windows for auxiliary functions. As noted in “ApplicationTypes” (page 91), Xcode provides a template for document-based applications. This template includesappropriately configured nib files and stub source files for the NSDocument subclass used to manage yourdocuments.

For information about the document architecture, read Mac App Programming Guide .

Views and ControlsSome of the ready-to-use views that AppKit offers are similar to UIKit views in form, function, and interface.But even with these views, there are differences you should be aware of when migrating your code. OtherUIKit views have no counterpart in AppKit because they would not work well in Mac OS X; for these views, youmust find a suitable alternative. For example, AppKit uses the NSBrowser class to manage the display ofhierarchical information rather than the UIKit paradigm of navigation controllers. Moreover, some views thatseem similar have different inheritance characteristics; for example, UITableView objects inherit from theUIScrollView class whereas NSTableView objects inherit from NSControl, the base class for controls inAppKit.

Even though the base classes for views on both platforms—UIView and NSView—are somewhat similar, thereare fundamental differences between them.

● Core Animation layers. iOS views are layer-backed by default. iOS applications typically manipulate viewsby changing properties of the view. In Mac OS X, an application must opt in to make its views layer backed.Consequently, it is more common for AppKit views to perform the same manipulations in their drawRect:method. Table 7-2 (page 99) gives more information about differences related to Core Animation layers.

● Default coordinate system. The default coordinate systems used in drawing operations are different iniOS and Mac OS X. In iOS, the drawing origin is at the upper-left corner of a view and positive coordinatesextend down and to the right; in Mac OS X, the drawing origin is at the lower-left corner of a view andpositive coordinates extend up and to the right. See “Graphics, Drawing, and Printing” (page 96) foradditional information.

Migrating from Cocoa TouchDifferences Between the UIKit and AppKit Frameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

94

Page 95: OSX Technology Overview

● Use of cells for controls. Because AppKit views can incur significant overhead, some AppKit controls usecells (that is, NSCell objects) as a lightweight alternative to views. A cell holds the information that itscontrol needs in order to send an action message; a cell also draws itself when commanded by its cell.Cells make possible controls such a matrix object and a table view that have two-dimensional arrays ofactive subregions.

For functional descriptions of the views and controls available in Mac OS X, along with information on how touse them, see OS X Human Interface Guidelines . To learn about the common characteristics and behavior ofAppKit views, see View Programming Guide . For information about AppKit controls, read Control and CellProgramming Topics .

File SystemMany Mac OS X applications let users locate files and directories in the file system, save files to specific file-systemlocations, open files, and do other file-system operations. An iOS application, on the other hand, must performall file-reading and file-writing operations within the confines of its sandbox. Beginning in Mac OS X v10.7,desktop and laptop applications can also be “sandboxed” (see “App Sandbox” (page 66)), and this can restrictthe file-system operations they can perform. Nonetheless, even these applications might have to be preparedto open and save files in the file system as the user directs (assuming that the user has the necessary filepermissions).

An application in Mac OS X enables these file-system behaviors largely through the Open and Save panels(implemented by the AppKit classes NSOpenPanel and NSSavePanel). Through instances of these objects,the application can present file-system browsers to users, prevent files it doesn’t recognize from being selected,and obtain users’ choices. You can also attach custom accessory views to these browsers.

In addition to making use of the Open and Save panels, your application can call methods of theNSFileManager and NSWorkspace classes for many file-system interactions. NSFileManager lets yourapplication create, move, copy, remove, and link file-system items. It also offers other capabilities, such asdiscovering directory contents and getting and setting file and directory attributes. Operations of theNSWorkspace class augment those of NSFileManager; these operations include launching applications,opening specific files, mounting local volumes and removable media, setting the Finder information of filesand directories, and tracking file-system changes. (Sandboxed applications won’t be able to use NSWorkspacein many situations.)

If your iOS application writes and reads files in the Documents directory, it uses theNSSearchPathForDirectoriesInDomains function to get the proper directory path in the applicationsandbox. In Mac OS X, you use the URLsForDirectory:inDomains: method of the NSFileManager classinstead; for this platform you might need to specify domains other than the user domain, and standard directorylocations other than Documents. For example, your application might want to write or read data in theLibrary/Application Support folder in the user’s home directory.

Migrating from Cocoa TouchDifferences Between the UIKit and AppKit Frameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

95

Page 96: OSX Technology Overview

Note Mac OS X applications should not store files in ~/Documents unless the user selects thatlocation using the Save panel. They should always store files they create in an appropriate locationin the user’s Library directory.

To learn more about file-system domains, standard file-system locations, filename extensions, BSD filepermissions, AppKit facilities for managing file-system operations, and other information related to the MacOS X file system, read File System Programming Guide .

Graphics, Drawing, and PrintingThere are many parallels between the graphics and drawing APIs of AppKit and those of UIKit, as shown inTable 7-1. Both frameworks have classes whose instances represent images, colors, and fonts. Both have classesfor drawing Bezier paths and categories for drawing strings. Both have functions for stroking and fillingrectangles. Both have programmatic facilities for obtaining and transforming graphics contexts of varioustypes. In some cases, you can migrate code that uses UIKit methods and functions to corresponding AppKitmethods and functions with little more than name changes.

Table 7-1 Comparison of graphics, drawing, and printing APIs

CommentsMac OS X (AppKit)iOS (UIKit)

NSImage can render an imagefrom source data appropriate toan output destination.

NSImageUIImageImages

Applications can useNSColorSpace to more preciselydefine the colors represented byNSColor objects.

NSColor,NSColorSpace,color-related viewclasses

UIColorColors

NSBezierPathUIBezierPathBezierpaths

NSGraphicsContextFunctions declared inUIGraphics.h.

Graphicscontexts

The PDF support in Mac OS X ismuch richer.

PDF Kit frameworkFunctions declared inUIGraphics.h.

PDF

The classes and techniques forprinting in each platform arecompletely different.

Multiple classesMultiple classes (iOS4.2 and later)

Printing

Migrating from Cocoa TouchDifferences Between the UIKit and AppKit Frameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

96

Page 97: OSX Technology Overview

As when using UIKit to draw or perform other graphical operations, you can call Core Graphics functions whenthe methods or functions of AppKit don’t suffice for a particular purpose.

The drawing model for AppKit views is nearly identical to the model in UIKit, with one exception. UIKit viewsuse a coordinate system where the origin for windows and views is in the upper-left corner by default, withpositive axes extending down and to the right. In AppKit, the default origin point is in the bottom-left cornerand the positive axes extend up and to the right. This is the default coordinate system of AppKit, which happensto coincide with the default coordinate system of Core Graphics.

Note Whereas UIKit uses Core Graphics data types for rectangles, points, and other geometricprimitives, AppKit uses its own defined types for the same purpose—for example, NSRect andNSPoint.

For information about graphics and drawing in Mac OS X, see Cocoa Drawing Guide . To learn how to print inMac OS X, see Printing Programming Topics for Cocoa .

TextAppKit offers applications a sophisticated system for performing text-related tasks ranging from simple textentry to custom text layout and typesetting. The Cocoa text system is based on the Core Text framework, andit provides a comparable set of behaviors; thus, Cocoa applications in Mac OS X rarely need to use Core Textdirectly.

The native text support of UIKit is limited. Still there is some correspondence between that support and thesupport offered by AppKit—namely, text views, text fields, font objects, string drawing, and HTML content. Ifyour iOS application uses Core Text to draw and manage fonts and text layout, you can migrate much of thatcode to your Mac OS X application.

For an introduction to the text system of AppKit, see Cocoa Text Architecture Guide .

Table ViewsTable views in AppKit are structurally different from table views in UIKit. In UIKit, a table view has any numberof rows, and one or more sections; however it has only one column. In AppKit, a table view can have anynumber of rows and columns (and there is no formal notion of sections). An iOS application typically uses aseries of UIKit table views, each in their own screen, to cover a hierarchical data set. A Mac OS X application,on the other hand, typically uses a single AppKit table view to present all of a data set at the same time.

Migrating from Cocoa TouchDifferences Between the UIKit and AppKit Frameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

97

Page 98: OSX Technology Overview

The structures of these table views differ because of the differences between the platforms. Table views,perhaps the most versatile user-interface object in iOS, are ideal for displaying data on a smaller screen.Applications use them to navigate hierarchies of data, to present master-detail relationships among data, tofacilitate quick retrieval of indexed items, and to serve as lists from which users can select options.

Table views in Mac OS X exist largely to present tabular data in a larger window. AppKit has other user-interfaceobjects that are suitable for some of the roles played by UIKit table views—for example, lists (pop-up lists,checkboxes, and radio buttons) and navigation of data hierarchies (browsers and outline views). Consequently,when you migrate your application’s table views to Mac OS X, you should first consider whether another AppKitview better suits your application’s needs than a table view.

Table views in AppKit are NSTableView objects. Cells occupy the region where the rows and columns of thetable view intersect. A table view’s cells can be based on NSCell objects or, with Mac OS X v10.7, NSViewobjects. View-based table views are the preferred alternative. Populating AppKit table views is similar topopulating UIKit table views: A data source is queried for the number of rows in the table view and is thenasked for the value to put into each cell. Table views in Mac OS X have these other parallels with UIKit tableviews:

● Cell reuse. The delegate of a view-based table view can return a view to use for a cell; the view has anidentifier. On the first request, the table view loads this view from a nib file and then caches the view forsubsequent requests.

● Animated operations. Both NSCell-based and NSView-based table views have methods for inserting,removing, and moving rows and items, optionally with an animation.

NSOutlineView, a subclass of NSTableView, has many of these same behaviors. For more information aboutcreating and using table views, see Table View Programming Guide .

Other Interface DifferencesWhen migrating your application, you should keep in mind other technology differences between UIKit andAppKit; Table 7-2 summarizes these differences.

Migrating from Cocoa TouchDifferences Between the UIKit and AppKit Frameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

98

Page 99: OSX Technology Overview

Table 7-2 Differences between UIKit and AppKit in interface technologies

DiscussionDifference

Every drawing surface in Mac OS X can be backed by a Core Animation layer (as iniOS), but an application has to explicitly request this backing for its views. Once thisrequest is made, animation is supported for changes in the properties of the views.In AppKit you don’t get the same easy-to-use view-based animation support that youdo in UIKit.

AppKit also includes the animation features of layer hosting, animation proxies, andclasses for animating multiple windows and views.

For information about the animation capabilities and features of Mac OS X, seeAnimation Overview .

CoreAnimationlayers

Target-action in AppKit defines only one form for method signatures, unlike UIKit,which has three forms. Controls in AppKit send their action messages in response toa discrete user action, such as a mouse click; the notion of multiple actions associatedwith multiple interaction phases does not exist on the platform. However, a controlcomposed of multiple cells can send a different action message for each cell.

For more information about controls and the target-action model in Mac OS Xapplications, see Control and Cell Programming Topics .

Target-actionmodel

The responder chain in Mac OS X differs slightly from the responder chain in iOS. InMac OS X, view controllers are not part of the chain for either user events or actionmessages (as they are in UIKit). For action messages, the responder chain in Mac OSX includes window controllers and the view hierarchies of key windows and mainwindows. AppKit also uses the responder chain for cooperative error handling.

To learn more about the responder chain, see Cocoa Event Handling Guide .

Responderchain

In Mac OS X, all preferences belong in your application; there is no separation ofpreferences between those managed by your application and those managed by thesystem. Mac OS X has nothing comparable to the Settings bundle used by iOSapplications to specify user preferences presented by the Settings application. Insteadapplications must create a secondary window for the user preferences. Users openthis window by choosing Preferences from the application menu. In addition, MacOS X integrates user preferences into Cocoa bindings and enables command-lineaccess to the underlying defaults system.

One commonality is that both AppKit and UIKit applications use the NSUserDefaultsclass to retrieve user preferences.

For more information, see Preferences and Settings Programming Guide .

Userpreferences

Migrating from Cocoa TouchDifferences Between the UIKit and AppKit Frameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

99

Page 100: OSX Technology Overview

DiscussionDifference

UIKit makes extensive use of properties throughout its class declarations, but AppKitmostly declares accessor methods instead of properties.

Accessormethodsversusproperties

Foundation Framework DifferencesA slightly different version of the Foundation framework in iOS is available in Mac OS X. Most of the classesyou would expect to be present are available in both versions; both framework versions provide support formanaging values, strings, collections, threads, and many other common types of data. There are, however,some technologies that are present in Foundation in Mac OS X but not included in iOS. These technologiesare listed in Table 7-3.

Table 7-3 Foundation technologies available in Mac OS X but not in iOS

NotesTechnology

Spotlight is a technology for organizing and accessing information on acomputer using file metadata. (Metadata is data about a file, rather than theactual file contents.) If you want your application to create Spotlight queriesand interact with the results, you use special query and predicate objects.

For more information, see Spotlight Overview .

Spotlight metadatamanagement

Cocoa bindings is a technology that lets you, during development, establisha connection between an item of data encapsulated by a model object andthe presentation of that data in a view. It eliminates the need for glue codein the controller layer of an application.

See Cocoa Bindings Programming Topics for more information.

Cocoa bindings

Using certain classes of Foundation along with supporting technology, youcan make an application scriptable. A scriptable application is one thatresponds to commands in AppleScript scripts.

See Cocoa Scripting Guide to learn more about this technology.

Cocoa scripting(AppleScript)

Migrating from Cocoa TouchFoundation Framework Differences

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

100

Page 101: OSX Technology Overview

NotesTechnology

Distributed objects is an interprocess messaging technology. With distributedobjects, an object in an application can send a message to an object in adifferent Cocoa application in the same network or in a different network. Theport name server is an object that provides a port-registration service todistributed objects.

For information about this technology, see Distributed Objects ProgrammingTopics .

Distributed objectsand port name servermanagement

The Foundation framework in Mac OS X provides support for both event-driven and tree-based XML processing.The NSXMLParser class (also available in iOS) supports the parsing of a stream of XML. In addition, theframework provides the NSXML classes (so called because the names of these classes begin with “NSXML”).Instances of these classes represent an XML document as a tree structure of nodes, including elements andattributes.

For a list of the specific classes that are available in Mac OS X but not in iOS, see the class hierarchy diagramin “The Foundation Framework” in Foundation Framework Reference .

Differences in the Audio and Video FrameworksThe primary framework for audiovisual media in Mac OS X and iOS is AV Foundation. The programmaticinterfaces of the framework are almost the same in each platform. Just about any code you write using theiOS version of the framework should be valid with the Mac OS X version. The presentation of audiovisual media,however, is different on the two platforms—specifically, Mac OS X does not have the Media Player framework.

There are substantial differences between the audio frameworks of iOS and the audio frameworks of Mac OSX. The following are the audio technologies of Mac OS X (as of Mac OS X v10.7) that are not present in iOS:

● Programmatic interfaces in the Audio Unit framework for creating dynamically-loadable plug-ins for audioprocessing (audio units) and conversion (audio codecs), along with bundled user interfaces for audio units

● Additional built-in audio units and audio codecs, along with additional capabilities in like-named audiounits

● Programmatic interfaces in the Core Audio framework for interacting with audio hardware

● Programmatic interfaces in the I/O Kit framework for creating and using audio drivers

● Additional capabilities in the OpenAL framework, such as the ability to record audio and to use multichannelaudio and surround sound

● Programmatic interfaces in the Core MIDI framework for music sequencing

Migrating from Cocoa TouchDifferences in the Audio and Video Frameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

101

Page 102: OSX Technology Overview

● Audio development tools (AU Lab, auval, afconvert)

Note AV Foundation includes classes for playing and recording audio. These classes are adequateto the audio needs of many applications.

iOS, on the other hand, has audio technologies that you do not find in Mac OS X—for example, the MediaPlayer framework, the vibration capabilities of the Audio Toolbox framework, the programmatic interfaces forinput clicks, and the audio-session interfaces in the Audio Toolbox and AV Foundation frameworks, includingthe notions of audio session categories, interruptions, and route changes.

Mac OS X also offers Quick Time, a legacy set of multimedia technologies for playing, creating, editing, importing,compressing, and streaming media of various types. Quick Time is available in both Mac OS X and Windowssystems.

To learn more about AV Foundation, see AV Foundation Programming Guide .

Differences in Other Frameworks Common to Both PlatformsTable 7-4 lists the key differences in other Mac OS X frameworks from their counterparts in iOS.

Table 7-4 Differences in frameworks common to iOS and Mac OS X

DifferencesFramework

This framework contains the interfaces for accessing user contacts.Although it shares the same name, the Mac OS X version of thisframework is very different from its iOS counterpart.

Mac OS X has no framework for presenting an interface for contacts,whereas iOS does.

For more information, see Address Book Programming Guide for MacOS X .

AddressBook.framework

This framework contains the Core Foundation Network interfaces.In Mac OS X, the CFNetwork framework is a subframework of anumbrella framework, Core Services. Most of the interfaces, however,are the same for iOS and Mac OS X.

For more information, see CFNetwork Framework Reference .

CFNetwork.framework

Migrating from Cocoa TouchDifferences in Other Frameworks Common to Both Platforms

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

102

Page 103: OSX Technology Overview

DifferencesFramework

This framework contains the Quartz interfaces. You can use Quartzto create paths, gradients, shadings, patterns, colors, images, andbitmaps in exactly the same way you do in iOS. The Mac OS X versionof Quartz has features not present in iOS, including PostScriptsupport, image sources and destinations, Quartz Display Servicessupport, and Quartz Event Services support. In Mac OS X, the CoreGraphics framework is a subframework of the Application Servicesumbrella framework and is not a top-level framework, as it is in iOS.

For more information, see Quartz 2D Programming Guide .

CoreGraphics.framework

Mac OS X uses OpenGL instead of the OpenGL ES framework usedin iOS. This fuller-featured version of OpenGL is intended for desktopsystems. The programmatic interface of OpenGL is much larger thanthe one for OpenGLES. OpenGL has many extensions that are notavailable in the embedded version of the framework.

For information about the OpenGL support in Mac OS X, seeOpenGLProgramming Guide for Mac OS X .

OpenGL.framework

This framework contains the Core Animation, Core Image, and CoreVideo interfaces. Most of the Core Animation interfaces are the samefor Mac OS X and iOS. However, the iOS version of the frameworklacks the API support for layout constraints and Core Image filtersfound in the Mac OS X version.

For more information, see Quartz Core Framework Reference .

QuartzCore.framework

This framework contains the security interfaces. Its Mac OS X versionincludes more capabilities and programmatic interfaces. It hasauthentication and authorization interfaces and supports the displayof certificate contents. In addition, its keychain interfaces are morecomprehensive than the ones used in iOS.

For information about the security support in Mac OS X, see SecurityOverview .

Security.framework

This framework contains networking interfaces. The Mac OS X versioncontains the complete interfaces, not just the reachability interfacesyou find in iOS.

For more information, see System Configuration ProgrammingGuidelines .

System-Configuration.framework

Migrating from Cocoa TouchDifferences in Other Frameworks Common to Both Platforms

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

103

Page 104: OSX Technology Overview

This appendix contains information about the frameworks of Mac OS X. These frameworks provide the interfacesyou need to write software for the platform. Some of these frameworks contain simple sets of interfaces whileothers contain multiple subframeworks. Where applicable, the tables in this appendix list any key prefixes usedby the classes, methods, functions, types, or constants of the framework. You should avoid using any of thespecified prefixes in your own symbol names.

System FrameworksTable A-1 describes the frameworks located in the /System/Library/Frameworks directory and lists thefirst version of Mac OS X in which each became available.

Table A-1 System frameworks

DescriptionPrefixesFirstavailable

Name

Umbrella framework forvector-optimized operations. See“Accelerate Framework” (page 113).

cblas,vDSP, vv

10.3Accelerate.framework

Contains functions for creating andaccessing a systemwide database ofcontact information.

AB, ABV10.2AddressBook.framework

Contains Carbon interfaces forOpenGL.

AGL, GL,glm, GLM,glu, GLU

10.0AGL.framework

Contains classes and methods for theCocoa user-interface layer. In general,link to Cocoa.framework instead ofthis framework.

NS10.0AppKit.framework

Deprecated. UseAppKit.frameworkinstead.

N/A10.0AppKit-Scripting.framework

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

104

Mac OS X Frameworks

Page 105: OSX Technology Overview

DescriptionPrefixesFirstavailable

Name

Contains interfaces for creatingAppleScript plug-ins.

ASK10.0AppleScriptKit.framework

Contains Objective-C extensions forcreating AppleScript plug-ins.

NS10.6AppleScriptObj-C.framework

Contains utilities for handling URLs inAppleShare clients.

AFP10.0AppleShareClient-Core.framework

Umbrella framework for severalapplication-level services. See“Application ServicesFramework” (page 114).

AE, AX,ATSU, CG,CT, LS,PM, QD, UT

10.0Application-Services.framework

Contains interfaces for getting audiostream data, routing audio signalsthrough audio units, convertingbetween audio formats, and playingback music.

AU,AUMIDI

10.0AudioToolbox.framework

Contains interfaces for defining CoreAudio plug-ins.

AU10.0AudioUnit.framework

Umbrella framework for creatingAutomator plug-ins. See “AutomatorFramework” (page 114).

AM10.4Automator.framework

Provides interfaces for playing,recording, inspecting, and editingaudiovisual media.

AV10.7AVFoundation.framework

Contains interfaces for managing iCalcalendar data.

Cal10.5CalendarStore.framework

Umbrella framework for Carbon-levelservices. See “CarbonFramework” (page 115).

HI, HR,ICA, ICD,Ink, Nav,OSA, PM,SFS,SR

10.0Carbon.framework

Wrapper for including the Cocoaframeworks AppKit.framework,Foundation.framework, andCoreData.framework.

NS10.0Cocoa.framework

Mac OS X FrameworksSystem Frameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

105

Page 106: OSX Technology Overview

DescriptionPrefixesFirstavailable

Name

Contains interfaces for managingidentity information.

CB10.5Collaboration.framework

Contains the hardware abstractionlayer interface for manipulating audio.

Audio10.0CoreAudio.framework

Contains Objective-C interfaces foraudio unit custom views.

AU10.4CoreAudioKit.framework

Contains interfaces for managing yourapplication’s data model.

NS10.4CoreData.framework

Provides fundamental softwareservices, including abstractions forcommon data types, string utilities,collection utilities, plug-in support,resource management, preferences,and XML parsing.

CF10.0CoreFoundation.framework

Provides interfaces for determiningthe geographical location of acomputer.

CL10.6CoreLocation.framework

Contains low-level interfaces for formanaging and and playingaudio-visual media in an application.

CM10.7CoreMedia.framework

Contains interfaces of the DeviceAbstraction Layer (DAL) used forcreating plug-ins that can accessmedia hardware.

CMIO10.7CoreMediaIO.framework

Contains utilities for implementingMIDI client programs.

MIDI10.0CoreMIDI.framework

Contains interfaces for creating MIDIdrivers to be used by the system.

MIDI10.0CoreMIDIServer.framework

Umbrella framework for system-levelservices. See “Core ServicesFramework” (page 116).

CF, DCS,MD, SK, WS

10.0CoreServices.framework

Contains interfaces for managingvideo-based content.

CV10.5CoreVideo.framework

Mac OS X FrameworksSystem Frameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

106

Page 107: OSX Technology Overview

DescriptionPrefixesFirstavailable

Name

Contains interfaces for managingwireless networks.

CW10.6CoreWLAN.framework

Contains interfaces for displayingsharing account information andother identity-related information.

CB10.5Collaboration.framework

Contains interfaces for supportingnetwork-based lookup and directoryservices in your application. You canalso use this framework to developdirectory service plug-ins.

ds10.0Directory-Service.framework

Contains interfaces for burning datato CDs and DVDs.

DR10.2DiscRecording.framework

Contains the user interface layer forinteracting with users during theburning of CDs and DVDs.

DR10.2DiscRecording-UI.framework

Contains interfaces for gettinginformation related to local andremote volumes.

DA10.4Disk-Arbitration.framework

Contains the game sprocketcomponent for drawing content tothe screen.

DSp10.0DrawSprocket.framework

Contains interfaces forcommunicating with digital videodevices, such as video cameras.

IDH10.0DVComponent-Glue.framework

Contains interfaces for embeddingDVD playback features into yourapplication.

DVD10.3DVDPlayback.framework

Contains exception-handling classesfor Cocoa applications.

NS10.0Exception-Handling.framework

Contains interfaces forcommunicating with forcefeedback–enabled devices.

FF10.2ForceFeedback.framework

Mac OS X FrameworksSystem Frameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

107

Page 108: OSX Technology Overview

DescriptionPrefixesFirstavailable

Name

Contains the classes and methods forthe Cocoa Foundation layer. If you arecreating a Cocoa application, linkingto the Cocoa framework is preferable.

NS10.0Foundation.framework

Contains interfaces forcommunicating with FireWire-basedaudio devices.

FWA10.2FWAUserLib.framework

Contains interfaces for the OpenGLUtility Toolkit, which provides aplatform-independent interface formanaging windows.

glut,GLUT

10.0GLUT.framework

Contains interfaces for GenericSecurity Services Application ProgramInterface (GSSAPI).

gss10.7GSS.framework

Contains low-level interfaces forcommunicating with digital devicessuch as scanners and cameras. Seealso, “Carbon Framework” (page 115).

ICD10.3ICADevices.framework

Deprecated. Use ImageCapture-Core.framework instead.

ICD10.3ImageCapture.framework

Contains Objective-C interfaces forcommunicating with digital devicessuch as scanners and cameras.

IC10.6ImageCapture-Core.framework

Do not use.IM10.6IMCore.framework

Contains interfaces for buildingthird-party plug-ins for Chat services.Umbrella framework forIMServicePlugIn-Support.framework.

IM10.7IMServicePlug-In.framework

Contains interfaces for developingnew input methods, which aremodules that handle text entry forcomplex languages.

IMK10.5InputMethodKit.framework

Mac OS X FrameworksSystem Frameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

108

Page 109: OSX Technology Overview

DescriptionPrefixesFirstavailable

Name

Contains interfaces for creatingplug-ins that run during softwareinstallation sessions.

IFX10.4Installer-Plugins.framework

Contains interfaces for obtaining theonline status of an instant messaginguser.

FZ, IM10.4InstantMessage.framework

Contains interfaces forcommunicating with Bluetoothdevices.

IO10.2IOBluetooth.framework

Contains the user interface layer forinteracting with users manipulatingBluetooth devices.

IO10.2IOBluetoothUI.framework

Contains the main interfaces forcreating user-space device drivers andfor interacting with kernel-residentdrivers from user space.

IO,IOBSD,IOCF

10.0IOKit.framework

Contains low-level interfaces forsharing graphics surfaces betweenapplications.

IO10.6IOSurface.framework

Contains interfaces for embeddingJava frames in Objective-C code.

N/A10.5JavaFrame-Embedding.framework

Contains the library and resources forexecuting JavaScript code within anHTML page. (Prior to Mac OS X v10.5,this framework was part ofWebKit.framework.

JS10.5JavaScriptCore.framework

Contains the system’s JavaDevelopment Kit resources.

JAWT,JDWP,JMM, JNI,JVMDI,JVMPI,JVMTI

10.0JavaVM.framework

Contains interfaces for using theKerberos network authenticationprotocol.

GSS, KL,KRB,KRB5

10.0Kerberos.framework

Mac OS X FrameworksSystem Frameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

109

Page 110: OSX Technology Overview

DescriptionPrefixesFirstavailable

Name

Contains the interfaces forkernel-extension development,including Mach, BSD, libkern, I/O Kit,and the various families built on topof I/O Kit.

numerous10.0Kernel.framework

Contains interfaces for classifying textbased on latent semantic information.

LSM10.5LatentSemantic-Mapping.framework

Do not use.N/A10.0LDAP.framework

Contains Cocoa extensions for maildelivery.

AS, MF,PO, POP,RSS, TOC,UR, URL

10.0Message.framework

Contains interfaces for working withnetwork file systems.

NetFS10.6NetFS.framework

Contains the interfaces for OpenAL, across-platform 3D audio deliverylibrary.

AL10.4OpenAL.framework

Contains the interfaces fordistributing general-purposecomputational tasks across theavailable GPUs and CPUs of acomputer.

CL, cl10.6OpenCL.framework

Contains Objective-C interfaces formanaging Open Directoryinformation.

OD10.6OpenDirectory.framework

Contains the interfaces for OpenGL,which is a cross-platform 2D and 3Dgraphics rendering library.

CGL, GL,glu, GLU

10.0OpenGL.framework

Contains Objective-C interfaces formanaging and executingOSA-compliant scripts from yourCocoa applications.

OSA10.4OSAKit.framework

Mac OS X FrameworksSystem Frameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

110

Page 111: OSX Technology Overview

DescriptionPrefixesFirstavailable

Name

Contains interfaces for interactingwith smart card devices.

MSC,Scard,SCARD

10.0PCSC.framework

Contains interfaces for implementingcustom modules for the SystemPreferences application.

NS10.0Preference-Panes.framework

Contains interfaces for subscribing toRSS and Atom feeds.

PS10.5PubSub.framework

Contains the open source Pythonscripting language interfaces.

Py10.3Python.framework

Contains Objective-C interfaces formanipulating QuickTime content.

QT10.4QTKit.framework

Umbrella framework for Quartzservices. See “QuartzFramework” (page 117)

GF, PDF,QC, QCP

10.4Quartz.framework

Contains the interfaces for CoreImage, Core Animation, and CoreVideo.

CA,CI, CV10.4QuartzCore.framework

Contains interfaces for generatingthumbnail previews of documents.

QL10.5QuickLook.framework

Contains interfaces for embeddingQuickTime multimedia into yourapplication.

N/A10.0QuickTime.framework

Contains interfaces for the Rubyscripting language.

N/A10.5Ruby.framework

Contains interfaces for running Rubyscripts from Objective-C code.

RB10.5RubyCocoa.framework

Contains interfaces for writing screensavers.

N/A10.0ScreenSaver.framework

Deprecated. UseFoundation.framework instead.

NS10.0Scripting.framework

Mac OS X FrameworksSystem Frameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

111

Page 112: OSX Technology Overview

DescriptionPrefixesFirstavailable

Name

Contains interfaces for running scriptsfrom Objective-C code.

SB10.5Scripting-Bridge.framework

Contains interfaces for system-leveluser authentication and authorization.

CSSM,Sec

10.0Security.framework

Contains Cocoa interfaces forauthorizing users.

Sec10.3Security-Foundation.framework

Contains the user interface layer forauthorizing users in Cocoaapplications.

PSA, SF10.3Security-Interface.framework

Contains Objective-C interfaces forsending and receiving server-basednotifications.

NS10.6Server-Notification.framework

Contains interfaces for loading,unloading and managing launchdservices.

SM10.6Service-Management.framework

Deprecated in Mac OS X v10.7.ISync10.4SyncServices.framework

Do not use.N/A10.0System.framework

Contains interfaces for accessingnetwork configuration andreachability. information.

SC10.0System-Configuration.framework

Contains interfaces for accessing thesystem’s Tcl interpreter from anapplication.

Tcl10.3Tcl.framework

Contains interfaces for accessing thesystem’s Tk toolbox from anapplication.

Tk10.4Tk.framework

Contains interfaces for accessingTWAIN-compliant image-scanninghardware.

TW10.2TWAIN.framework

Mac OS X FrameworksSystem Frameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

112

Page 113: OSX Technology Overview

DescriptionPrefixesFirstavailable

Name

Deprecated. UseAccelerate.framework instead.See “Accelerate Framework” (page113).

N/A10.0vecLib.framework

Contains interfaces for usinghardware resources for acceleratedvideo decoding.

VDA10.7VideoDecode-Acceleration.framework

Umbrella framework for renderingHTML content. See “WebKitFramework” (page 117).

DOM, Web10.2WebKit.framework

Contains interfaces for connecting toand managing computing clustersoftware.

XG10.4Xgrid-Foundation.framework

Contains low-level interfaces forinterprocess communication.

N/A10.7XPCService.framework

Mac OS X contains several umbrella frameworks for major areas of functionality. Umbrella frameworks groupseveral related frameworks into a larger framework that can be included in your project. When writing software,link your project against the umbrella framework; do not try to link directly to any of its subframeworks. Thefollowing sections describe the contents of the umbrella frameworks in Mac OS X.

Accelerate FrameworkTable A-2 lists the subframeworks of the Accelerate framework (Accelerate.framework). If you are developingapplications for earlier versions of Mac OS X, vecLib.framework is available as a standalone framework.

Table A-2 Subframeworks of the Accelerate framework

DescriptionSubframework

Contains vector-optimized interfaces for performing math, big-number, andDSP calculations, among others.

vecLib.framework

Contains vector-optimized interfaces for manipulating image data.vImage.framework

Mac OS X FrameworksSystem Frameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

113

Page 114: OSX Technology Overview

Application Services FrameworkTable A-3 lists the subframeworks of the Application Services framework (ApplicationServices.framework).These frameworks provide C-based interfaces and are intended primarily for Carbon applications, althoughother programs can use them. The listed frameworks are available in all versions of Mac OS X unless otherwisenoted.

Table A-3 Subframeworks of the Application Services framework

DescriptionSubframework

Contains interfaces for font layout and management using AppleType Services.

ATS.framework

Contains interfaces for color matching using ColorSync.ColorSync.framework

Contains the Quartz interfaces for creating graphic content andrendering that content to the screen.

CoreGraphics.framework

Contains the interfaces for performing text layout and display.Available in Mac OS X v10.5 and later.

CoreText.framework

Contains interfaces for accessibility, Internet Config, thepasteboard, the Process Manager, and the Translation Manager.Available in Mac OS X 10.2 and later.

HIServices.framework

Contains interfaces for importing and exporting image data. Priorto Mac OS X v10.5, these interfaces were part of the CoreGraphicssubframework.

ImageIO.framework

Contains the Language Analysis Manager interfaces.LangAnalysis.framework

Contains the Core Printing Manager interfaces.PrintCore.framework

Contains the QuickDraw interfaces.QD.framework

Contains the Speech Manager interfaces.SpeechSynthesis.framework

Automator FrameworkTable A-4 lists the subframeworks of the Automator framework (Automator.framework).

Mac OS X FrameworksSystem Frameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

114

Page 115: OSX Technology Overview

Table A-4 Subframeworks of the Automator framework

DescriptionSubframework

Contains private interfaces for managing Automator plug-ins.MediaBrowser.framework

Carbon FrameworkTable A-5 lists the subframeworks of the Carbon framework (Carbon.framework). The listed frameworks areavailable in all versions of Mac OS X unless otherwise noted.

Table A-5 Subframeworks of the Carbon framework

DescriptionSubframework

Contains the Sound Manager interfaces. Whenever possible, useCore Audio instead.

CarbonSound.framework

Contains interfaces for displaying the Font window, Color window,and some network-related dialogs.

CommonPanels.framework

Contains interfaces for launching and searching Apple Help.Help.framework

Contains interfaces for the Carbon Event Manager, HIToolboxobject, and other user interface–related managers.

HIToolbox.framework

Contains interfaces for rendering HTML content. The WebKitframework is the preferred framework for HTML rendering. See“WebKit Framework” (page 117).

HTMLRendering.framework

Contains interfaces for capturing images from digital cameras. Thisframework works in conjunction with the Image Capture Devicesframework (ICADevices.framework).

ImageCapture.framework

Contains interfaces for managing pen-based input. (Ink events aredefined with the Carbon Event Manager.)

Ink.framework

Contains interfaces for displaying file navigation dialogs.Navigation-Services.framework

Contains interfaces for writing scripting components and interactingwith those components to manipulate and execute scripts.

OpenScripting.framework

Contains the Carbon Printing Manager interfaces for displayingprinting dialogs and extensions.

Print.framework

Contains interfaces for displaying security-related dialogs.SecurityHI.framework

Mac OS X FrameworksSystem Frameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

115

Page 116: OSX Technology Overview

DescriptionSubframework

Contains the Speech Recognition Manager interfaces.Speech-Recognition.framework

Core Services FrameworkTable A-6 lists the subframeworks of the Core Services framework (CoreServices.framework). Theseframeworks provide C-based interfaces and are intended primarily for Carbon applications, although otherprograms can use them. The listed frameworks are available in all versions of Mac OS X unless otherwise noted.

Table A-6 Subframeworks of the Core Services framework

DescriptionSubframework

Contains interfaces for creating and manipulating Apple eventsand making applications scriptable.

AE.framework

Contains interfaces for many legacy Carbon Managers. In MacOS X v10.5 and later, this subframework contains the FSEventsAPI, which notifies clients about file system changes.

CarbonCore.framework

Contains interfaces for network communication using HTTP,sockets, and Bonjour.

CFNetwork.framework

Provides dictionary lookup capabilities.Dictionary-Services.framework

Contains interfaces for launching applications.LaunchServices.framework

Contains interfaces for managing Spotlight metadata.Metadata.framework

Contains interfaces for Open Transport and manyhardware-related legacy Carbon managers.

OSServices.framework

Contains interfaces for the Search Kit.SearchKit.framework

IMCore FrameworkTable A-8 lists the subframeworks of the IMCore framework (IMCore.framework). This framework wasintroduced in Mac OS X version 10.6.

Mac OS X FrameworksSystem Frameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

116

Page 117: OSX Technology Overview

Table A-7 Subframeworks of the IMCore framework

DescriptionSubframework

Contains private interfaces.IMDaemonCore.framework

Contains private interfaces.IMFoundation.framework

Contains private interfaces.IMSecurityUtils.framework

Contains private interfaces.IMUtils.framework

Contains private interfaces.XMPPCore.framework

Quartz FrameworkTable A-8 lists the subframeworks of the Quartz framework (Quartz.framework).

Table A-8 Subframeworks of the Quartz framework

DescriptionSubframework

Contains Objective-C interfaces for finding, browsing, and displayingimages. Available in Mac OS X version 10.5 and later.

ImageKit.framework

Contains Objective-C interfaces for displaying and managing PDFcontent in windows.

PDFKit.framework

Contains Objective-C interfaces for playing Quartz Composercompositions in an application.

QuartzComposer.framework

Contains Objective-C interfaces for managing and applying filtereffects to a graphics context. Available in Mac OS X version 10.5and later.

QuartzFilters.framework

WebKit FrameworkTable A-9 lists the subframeworks of the WebKit framework (WebKit.framework).

Table A-9 Subframeworks of the WebKit framework

DescriptionSubframework

Contains the library and resources for rendering HTML content in anHTMLView control.

WebCore.framework

Mac OS X FrameworksSystem Frameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

117

Page 118: OSX Technology Overview

Xcode FrameworksIn Mac OS X v10.5 and later, Xcode and all of its supporting tools and libraries reside in a portable directorystructure. This directory structure makes it possible to have multiple versions of Xcode installed on a singlesystem or to have Xcode installed on a portable hard drive that you plug in to your computer when you needto do development. This portability means that the frameworks required by the developer tools are installedin the <Xcode>/Library/Frameworks directory, where <Xcode> is the path to the Xcode installationdirectory. (The default Xcode installation directory is /Developer.) Table A-10 lists the frameworks that arelocated in this directory.

Table A-10 Xcode frameworks

DescriptionPrefixesFirstavailable

Framework

Unit-testing framework for C++ code.None10.4CPlusTest.framework

Contains interfaces for writing plug-insthat work in Interface Builder v3.0 andlater.

ib, IB10.5InterfaceBuilder-Kit.framework

Contains the interfaces for implementingunit tests in Objective-C.

Sen10.4SenTesting-Kit.framework

System LibrariesNote that some specialty libraries at the BSD level are not packaged as frameworks. Instead, Mac OS X includesmany dynamic libraries in the /usr/lib directory and its subdirectories. Dynamic shared libraries are identifiedby their .dylib extension. Header files for the libraries are located in /usr/include.

Mac OS X uses symbolic links to point to the most current version of most libraries. When linking to a dynamicshared library, use the symbolic link instead of a link to a specific version of the library. Library versions maychange in future versions of Mac OS X. If your software is linked to a specific version, that version might notalways be available on the user’s system.

Mac OS X FrameworksXcode Frameworks

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

118

Page 119: OSX Technology Overview

This table describes the changes to Mac Technology Overview .

NotesDate

Added descriptions for several new technologies first available in Mac OSX v10.7.

2012-01-09

Added a section on “iCloud Storage” (page 52).

Added a section on “Automatic Reference Counting” (page 53).

Added a section on “Popovers” (page 28).

Added a section on “Store Kit” (page 64).

Added a section on “In-Kernel Video Capture” (page 72).

Updated the sections on “Cocoa Auto Layout” (page 28), “FileCoordination” (page 53), “App Sandbox” (page 66), “Code Signing” (page67), “XPC Interprocess Communication and Services” (page 71), “AVFoundation” (page 43), “Core Data” (page 61), and “Foundation and CoreFoundation” (page 62).

Removed the section on Sync Services, which described a framework thatwas deprecated in Mac OS X v10.7. If you need information on SyncServices, see the Legacy Mac OS X Developer Library.

Updated document for Mac OS X v10.7, with extensive reorganizationand rewriting. Added the chapter "Migrating from Cocoa Touch."

2011-04-30

Updated for Mac OS X v10.6.2009-08-14

Removed outdated reference to jikes compiler. Marked theAppleShareClient framework as deprecated, which it was in Mac OS Xv10.5.

2008-10-15

Updated for Mac OS X v10.5. The document was also reorganized.2007-10-31

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

119

Document Revision History

Page 120: OSX Technology Overview

NotesDate

Associated in-use prefix information with the system frameworks. Clarifieddirectories containing developer tools.

2006-06-28

Added references to "Universal Binary Programming Guidelines."2005-10-04

Fixed minor typos. Updated environment variable inheritance information.2005-08-11

Incorporated developer feedback.2005-07-07

Added AppleScript to the list of application environments.

Corrected the man page name for SQLite.2005-06-04

Fixed broken links and incorporated user feedback.2005-04-29

Incorporated porting and technology guidelines from "Apple SoftwareDesign Guidelines." Added information about new system technologies.Changed "Rendezvous" to "Bonjour."

Added new software types to list of development opportunities.

Added a command-line primer.

Added a summary of the available development tools.

Updated the list of system frameworks.

First version of Mac OS X Technology Overview . Some of the informationin this document previously appeared in System Overview .

2004-05-27

Document Revision History

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

120

Page 121: OSX Technology Overview

abstract type Defines, in information property lists,general characteristics of a family of documents.Each abstract type has corresponding concrete types.See also concrete type.

Accessibility The technology for ensuring thatdisabled users can use Mac OS X. Accessibilityprovides support for disabled users in the form ofscreen readers, speech recognition, text-to-speechconverters, and mouse and keyboard alternatives.

ACLs Access Control Lists. A technology used togive fine-grained access to file-system objects.Compare with permissions.

action In the Automator application and framework,a modular unit that performs a discrete task, suchas opening a file, cropping an image, or sending amessage.

active window The frontmost modal or documentwindow. Only the contents of the active window areaffected by user actions. The active window hasdistinctive details that aren’t visible for inactivewindows.

Address Book A technology for managing names,addresses, phone numbers, and othercontact-related information. Mac OS X provides theAddress Book application for managing contact data.It also provides the Address Book framework so thatapplications can programmatically manage the data.

address space Describes the range of memory (bothphysical and virtual) that a process uses whilerunning. In Mac OS X, processes do not share addressspace.

alias A lightweight reference to files and folders inMac OS Standard (HFS) and Mac OS Extended (HFS+)file systems. An alias allows multiple references tofiles and folders without requiring multiple copiesof these items. Aliases are not as fragile as symboliclinks because they identify the volume and locationon disk of a referenced file or folder; the file or foldercan be moved around without breaking the alias.See also symbolic link.

anti-aliasing A technique that smoothes theroughness in images or sound caused by aliasing.During frequency sampling, aliasing generates afalse (alias) frequency along with the correct one.With images this produces a stair-step effect.Anti-aliasing corrects this by adjusting pixel positionsor setting pixel intensities so that there is a moregradual transition between pixels.

Apple event A high-level operating-system eventthat conforms to the Apple Event InterprocessMessaging Protocol (AEIMP). An Apple event typicallyconsists of a message from an application to itselfor to another application.

AppleScript An Apple-defined scripting language.AppleScript uses a natural language syntax to sendApple events to applications, commanding them toperform specific actions.

AppleTalk A suite of network protocols that isstandard on Macintosh computers and can beintegrated with other network systems, such as theInternet.

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

121

Glossary

Page 122: OSX Technology Overview

AppKit A Cocoa framework that implements anapplication’s user interface in Mac OS X. The AppKitframework provides a basic program structure forapplications that draw on the screen and respondto events. (AppKit is sometimes called ApplicationKit.)

application packaging Putting code and resourcesin the prescribed directory locations insideapplication bundles. “Application package” issometimes used synonymously with “applicationbundle.”

Aqua A set of guidelines that define the appearanceand behavior of Mac OS X applications. The Aquaguidelines bring a unique look to applications,integrating color, depth, clarity, translucence, andmotion to present a vibrant appearance. If you useCocoa to create your application’s interface, you getthe Aqua appearance automatically

ASCII American Standard Code for InformationInterchange. A 7-bit character set (commonlyrepresented using 8 bits) that defines 128 uniquecharacter codes. See also Unicode.

Auto Layout A rule-based user-interface layoutsystem designed to implement the layout guidelinesdescribed in OS X Human Interface Guidelines . Itexpresses a larger class of relationships and is moreintuitive to use than springs and struts.

bit depth The number of bits used to describesomething, such as the color of a pixel. Eachadditional bit in a binary number doubles thepossible information conveyed.

bitmap A data structure that represents thepositions and states of a corresponding set of pixels.

Bonjour Apple’s technology for zero-configurationnetworking. Bonjour enables dynamic discovery ofservices over a network.

BSD Berkeley Software Distribution. Formerly knownas the Berkeley version of UNIX, BSD is now simplycalled the BSD operating system. BSD provideslow-level features such as networking, threadmanagement, and process communication. It alsoincludes a command-shell environment formanaging system resources. The BSD portion of MacOS X is based on version 5 of the FreeBSDdistribution.

buffered window A window with a memory bufferin which all drawing is rendered. All graphics are firstdrawn in the buffer, and then the buffer is flushedto the screen.

bundle A directory in the file system that storesexecutable code and the software resources relatedto that code. Applications, plug-ins, and frameworksare types of bundles. Except for frameworks, bundlesare file packages, presented by the Finder as a singlefile.

bytecode Computer object code that is processedby a virtual machine. The virtual machine convertsgeneralized machine instructions into specificmachine instructions (instructions that a computer’sprocessor can understand). Bytecode is the result ofcompiling source language statements written inany language that supports this approach. See alsovirtual machine (VM).

Carbon A legacy application environment in MacOS X that features a set of procedural programminginterfaces derived from earlier versions of the MacOS. The Carbon API has been modified to workproperly with Mac OS X, especially with thefoundation of the operating system, the kernelenvironment. Carbon applications can run in MacOS X and Mac OS 9.

Glossary

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

122

Page 123: OSX Technology Overview

CFM Code Fragment Manager, the library managerand code loader for processes based on PEF(Preferred Executable Format) object files (in Carbon).

class In object-oriented languages such asObjective-C, a prototype for a particular kind ofobject. A class definition declares instance variablesand defines methods for all members of the class.Objects that belong to the same class have the sametypes of instance variables and have access to thesame methods (including the instance variables andmethods inherited from superclasses).

Classic An application environment in Mac OS Xthat lets you run non-Carbon legacy Mac OSsoftware. It supports programs built for bothPowerPC and 68000-family chip architectures andis fully integrated with the Finder and the otherapplication environments.

Clipboard A per-user server (also known as thepasteboard) that enables the transfer of databetween applications, including the Finder. Thisserver is shared by all running applications andcontains data that the user has cut or copied, as wellas other data that one application wants to transferto another, such as in dragging operations. Data inthe Clipboard is associated with a name thatindicates how it is to be used. You implementdata-transfer operations with the Clipboard usingCore Foundation Pasteboard Services or the CocoaNSPasteboard class. See also pasteboard.

Cocoa An advanced object-oriented developmentplatform in Mac OS X. Cocoa is a set of frameworksused for the rapid development of full-featuredapplications in the Objective-C language. It is basedon the integration of OpenStep and Appletechnologies.

code fragment In the CFM-based architecture, acode fragment is the basic unit for executable codeand its static data. All fragments share fundamentalproperties such as the basic structure and themethod of addressing code and data. A fragmentcan easily access code or data contained in anotherfragment. In addition, fragments that export itemscan be shared among multiple clients. A codefragment is structured according to the PreferredExecutable Format (PEF).

ColorSync An industry-standard architecture forreliably reproducing color images on various devices(such as scanners, video displays, and printers) andoperating systems.

compositing A method of overlaying separatelyrendered images into a final image. It encompassessimple copying as well as more sophisticatedoperations that take advantage of transparency.

concrete type Defines, in information property lists,specific characteristics of a type of document, suchas extensions and HFS+ type and creator codes. Eachconcrete type has corresponding abstract types. Seealso abstract type.

CUPS The Common UNIX Printing System; an opensource architecture commonly used by the UNIXcommunity to implement printing.

daemon A process that handles periodic servicerequests or forwards a request to another processfor handling. Daemons run continuously, usually inthe background, waking only to handle theirdesignated requests. For example, the httpddaemon responds to HTTP requests for webinformation.

Glossary

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

123

Page 124: OSX Technology Overview

Darwin Another name for the Mac OS X coreoperating system. The Darwin kernel is equivalentto the Mac OS X kernel plus the BSD libraries andcommands essential to the BSD Commandsenvironment. Darwin is an open source technology.

Dashboard A user technology for managingHTML-based programs called widgets (see widget).Activating the Dashboard via the F12 key displays alayer above the Mac OS X desktop that contains theuser’s current set of widgets.

Dashcode A graphical application used to build anddebug Dashboard widgets.

demand paging An operating system facility thatcauses pages of data to be read from disk intophysical memory as they are needed.

device driver A component of an operating systemthat deals with getting data to and from a device,as well as with the control of that device.

dispatch queue A Grand Central Dispatch (GCD)structure that you use to execute your application’stasks. GCD defines dispatch queues for executingtasks either serially or concurrently.

domain An area of the file system reserved forsoftware, documents, and resources, and limitingthe accessibility of those items. A domain issegregated from other domains. There are fourdomains: user, local, network, and system.

DVD An optical storage medium that providesgreater capacity and bandwidth than CD-ROM; DVDsare frequently used for multimedia as well as datastorage.

dyld See dynamic link editor.

dynamic link editor The library manager for codein the Mach-O executable format. The dynamic linkeditor is a dynamic library that “lives” in all Mach-Oprograms on the system. See also CFM; Mach-O.

dynamic linking The binding of modules, as aprogram executes, by the dynamic link editor.Usually the dynamic link editor binds modules intoa program lazily (that is, as they are used). Thusmodules not actually used during execution arenever bound into the program.

dynamic shared library A library whose code canbe shared by multiple, concurrently runningprograms. Programs share one physical copy of thelibrary code and do not require their own copies ofthat code. With dynamic shared libraries, a programnot only attempts to resolve all undefined symbolsat runtime, but attempts to do so only when thosesymbols are referenced during program execution.

encryption The conversion of data into a form,called ciphertext, that cannot be easily understoodby unauthorized people. The complementaryprocess, decryption, converts encrypted data backinto its original form.

Ethernet A high-speed local area networktechnology.

exception An interruption to the normal flow ofprogram control that occurs when an error or otherspecial condition is detected during execution. Anexception transfers control from the code generatingthe exception to another piece of code, generally aroutine called an exception handler.

fault In the virtual-memory system, faults are themechanism for initiating page-in activity. They areinterrupts that occur when code tries to access dataat a virtual address that is not mapped to physicalmemory. Soft faults happen when the referencedpage is resident in physical memory but is

Glossary

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

124

Page 125: OSX Technology Overview

unmapped. Hard (or page) faults occur when thepage has been swapped out to backing store. Seealso page; virtual memory.

file package A directory that the Finder presentsto users as if it were a file. In other words, the Finderhides the contents of the directory from users. Thisopacity discourages users from inadvertently (orintentionally) altering the contents of the directory.

file system A part of the kernel environment thatmanages the reading and writing of data onmounted storage devices of a certain volume format.A file system can also refer to the logical organizationof files used for storing and retrieving them. Filesystems specify conventions for naming files, storingdata in files, and specifying locations of files. Seealso volume format.

filters The simplest unit used to modify image datafrom Core Image. One or more filters may bepackaged into an image unit and loaded into aprogram using the Core image framework. Filterscan contain executable or nonexecutable code. Seealso image units.

firewall Software (or a computer running suchsoftware) that prevents unauthorized access to anetwork by users outside the network. (A physicalfirewall prevents the spread of fire between twophysical locations; a software firewall prevents theunauthorized spread of data.)

fork (1) A stream of data that can be opened andaccessed individually under a common filename.The Mac OS Standard and Extended file systemsstore a separate data fork and resource fork as partof every file; data in each fork can be accessed andmanipulated independently of the other. (2) In BSD,fork is a system call that creates a new process.

framebuffer A highly accessible part of video RAM(random-access memory) that continuously updatesand refreshes the data sent to the devices thatdisplay images onscreen.

framework A type of bundle that packages adynamic shared library with the resources that thelibrary requires, including header files and referencedocumentation.

Grand Central Dispatch (GCD) A technology forexecuting asynchronous tasks concurrently. GCD isavailable in Mac OS X v10.6 and later and is notavailable in iOS.

HFS Hierarchical File System. The Mac OS Standardfile-system format, used to represent a collection offiles as a hierarchy of directories (folders), each ofwhich may contain either files or other folders. HFSis a two-fork volume format.

HFS+ Hierarchical File System Plus. The Mac OSExtended file-system format. This format allowsfilenames longer than 31 characters, supportsUnicode representation of file and directory names,and supports efficient operation on very large disks.HFS+ is a multiple-fork volume format.

HIToolbox Human Interface Toolbox. A collectionof procedural APIs that apply an object-orientedmodel to windows, controls, and menus for Carbonapplications. The HI Toolbox supplements olderMacintosh Toolbox managers such as the ControlManager, Dialog Manager, Menu Manager, andWindow Manager from Mac OS 9.

host The computer that is running (is host to) aparticular program; used to refer to a computer ona network.

iCloud document storage An iCloud feature forstoring and sharing user documents and app data,suitable for files and directories.

Glossary

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

125

Page 126: OSX Technology Overview

iCloud key-value data storage An iCloud featurefor storing and sharing property list data types forpreferences, configuration settings, and othernoncritical information.

IDE An acronym meaning “integrated developmentenvironment”. An IDE is a program that typicallycombines text editing, compiling, and debuggingfeatures in one package in order to assist developerswith the creation of software.

image units A plug-in bundle for use with the CoreImage framework. Image units contain one or morefilters for manipulating image data.

information property list A property list thatcontains essential configuration information forbundles. A file named Info.plist (or aplatform-specific variant of that filename) containsthe information property list and is packaged insidethe bundle.

inheritance In object-oriented programming, theability of a superclass to pass its characteristics(methods and instance variables) on to its subclasses.

instance In object-oriented languages such asObjective-C, an object that belongs to (is a memberof) a particular class. Instances are created at runtimeaccording to the specification in the class definition.

Interface Builder An application or subsystem forcreating user interfaces. You use Interface Builder tobuild and configure your user interface using a setof standard components and save that data to aresource file that can be loaded into your programat runtime. Xcode 4.0 integrates Interface Builderfeatures; earlier, it was a separate application.

internationalization The design or modification ofa software product, including its online help anddocumentation, to facilitate localization.Internationalization of software typically involves

writing or modifying code to make use oflocale-aware operating-system services forappropriate localized text input, display, formatting,and manipulation. See also localization.

interprocess communication (IPC) A set ofprogramming interfaces that enables a process tocommunicate data or information to anotherprocess. Mechanisms for IPC exist in the differentlayers of the system, from Mach messaging in thekernel to distributed notifications and Apple eventsin the application environments. Each IPCmechanism has its own advantages and limitations,so it is not unusual for a program to use multiple IPCmechanisms. Other IPC mechanisms include pipes,named pipes, signals, message queueing,semaphores, shared memory, sockets, the Clipboard,and application services.

I/O Kit A collection of frameworks, libraries, tools,and other resources for creating device drivers inMac OS X. The I/O Kit framework uses a restrictedform of C++ to provide default behavior and anobject-oriented programming model for creatingcustom drivers.

iSync A tool for synchronizing Address Bookinformation.

kernel The complete Mac OS X coreoperating-system environment, which includesMach, BSD, the I/O Kit, file systems, and networkingcomponents. Also called the kernel environment.

key An arbitrary value (usually a string) used tolocate a piece of data in a data structure such as adictionary.

localization The adaptation of a software product,including its online help and documentation, for usein one or more regions of the world, other than theregion for which the original product was created.Localization of software can include translation of

Glossary

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

126

Page 127: OSX Technology Overview

user interface text, resizing of text-related graphicalelements, and replacement or modification of userinterface images and sound. See alsointernationalization.

lock A data structure used to synchronize access toa shared resource. The most common use for a lockis in multithreaded programs where multiple threadsneed access to global data. Only one thread can holdthe lock at a time; this thread is the only one thatcan modify the data during this period.

manager In Carbon, a library or set of relatedlibraries that define a programming interface.

Mach The lowest level of the Mac OS X kernelenvironment. Mach provides such basic services andabstractions as threads, tasks, ports, interprocesscommunication (IPC), scheduling, physical and virtualaddress space management, virtual memory, andtimers.

Mach-O Executable format of Mach object files. Seealso PEF.

main thread By default, a process has one thread,the main thread. If a process has multiple threads,the main thread is the first thread in the process. Auser process can use the POSIX threading API(pthread) to create other user threads.

major version A framework version specifierdesignating a framework that is incompatible withprograms linked with a previous version of theframework’s dynamic shared library.

makefile A specification file used by a build tool tocreate an executable version of an application. Amakefile details the files, dependencies, and rulesby which the application is built.

memory-mapped file A file whose contents aremapped into memory. The virtual-memory systemtransfers portions of these contents from the file to

physical memory in response to page faults. Thus,the disk file serves as backing store for the code ordata not immediately needed in physical memory.

memory protection A system of memorymanagement in which programs are prevented frombeing able to modify or corrupt the memorypartition of another program. Mac OS 9 does nothave memory protection; Mac OS X does.

method In object-oriented programming, aprocedure that can be executed by an object.

minor version A framework version specifierdesignating a framework that is compatible withprograms linked with later builds of the frameworkwithin the same major version.

multicast A process in which a single networkpacket may be addressed to multiple recipients.Multicast is used, for example, in streaming video,in which many megabytes of data are sent over thenetwork.

multihoming The ability to have multiple networkaddresses in one computer. For example,multihoming might be used to create a system inwhich one address is used to talk to hosts outside afirewall and the other to talk to hosts inside; theoperating system provides facilities for passinginformation between the two.

multitasking The concurrent execution of multipleprograms. Mac OS X uses preemptive multitasking,whereas Mac OS 9 uses cooperative multitasking.

network A group of hosts that can directlycommunicate with each other.

nib file A file containing resource data generatedby the Interface Builder application.

nonretained window A window without anoffscreen buffer for screen pixel values.

Glossary

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

127

Page 128: OSX Technology Overview

notification Generally, a programmatic mechanismfor alerting interested recipients (or “observers”) thatsome event has occurred during program execution.The observers can be users, other processes, or eventhe same process that originates the notification. InMac OS X, the term “notification” is used to identifyspecific mechanisms that are variations of the basicmeaning. In the kernel environment, “notification”is sometimes used to identify a message sent via IPCfrom kernel space to user space; an example of thisis an IPC notification sent from a device driver to thewindow server’s event queue. Distributednotifications provide a way for a process to broadcastan alert (along with additional data) to any otherprocess that makes itself an observer of thatnotification. Finally, the Notification Manager (aCarbon manager) lets background programs notifyusers—through blinking icons in the menu bar, bysounds, or by dialogs—that their intercession isrequired.

NFS Network File System. An NFS file server allowsusers on the network to share files on other hostsas if they were on their own local disks.

object A programming unit that groups togethera data structure (instance variables) and theoperations (methods) that can use or affect that data.Objects are the principal building blocks ofobject-oriented programs.

object file A file containing executable code anddata. Object files in the Mach-O executable formattake the suffix .o and are the product of compilationusing the GNU compiler (gcc). Multiple object filesare typically linked together along with requiredframeworks to create a program. See also codefragment; dynamic linking.

object wrapper Code that defines an object-basedinterface for a set of procedural interfaces. SomeCocoa objects wrap Carbon interfaces to provideparallel functionality between Cocoa and Carbonapplications.

Objective-C An object-oriented programminglanguage based on standard C and a runtime systemthat implements the dynamic functions of thelanguage. Objective-C’s few extensions to the Clanguage are mostly based on Smalltalk, one of thefirst object-oriented programming languages.Objective-C is available in the Cocoa applicationenvironment.

opaque type In Core Foundation and Carbon, anaggregate data type plus a suite of functions thatoperate on instances of that type. The individualfields of an initialized opaque type are hidden fromclients, but the type’s functions offer access to mostvalues of these fields. An opaque type is roughlyequivalent to a class in object-orientedprogramming.

Open Computing Language (OpenCL) Astandards-based technology for performinggeneral-purpose computations on a computer’sgraphics processor. For more information, seeOpenCL Programming Guide for Mac OS X .

OpenGL The Open Graphics Language; anindustry-wide standard for developing portable 2Dand 3D graphics applications. OpenGL consists ofan API and libraries that developers use to rendercontent in their applications.

open source A definition of software that includesfreely available access to source code, redistribution,modification, and derived works. The full definitionis available at www.opensource.org.

Glossary

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

128

Page 129: OSX Technology Overview

Open Transport Open Transport is a legacycommunications architecture for implementingnetwork protocols and other communicationfeatures on computers running the Mac OS. OpenTransport provides a set of programming interfacesthat supports, among other things, both theAppleTalk and TCP/IP protocols.

PackageMaker A tool that builds an installablesoftware package from the files you provide.

page The smallest unit, measured in bytes, ofinformation that the virtual memory system cantransfer between physical memory and backingstore. As a verb, page refers to transferring pagesbetween physical memory and backing store.

pasteboard Another name for the Clipboard.

PEF Preferred Executable Format. An executableformat understood by the Code Fragment Manager.See also Mach-O.

permissions In BSD, a set of attributes governingwho can read, write, and execute resources in thefile system. The output of the ls -l commandrepresents permissions as a nine-position codesegmented into three binary three-charactersubcodes; the first subcode gives the permissionsfor the owner of the file, the second for the groupthat the file belongs to, and the last for everyoneelse. For example, -rwxr-xr-- means that theowner of the file has read, write, execute permissions(rwx); the group has read and execute permissions(r-x); everyone else has only read permissions. Theleftmost position indicates whether this is a regularfile (-), a directory (d), a symbolic link (l), or a specialpseudo-file device (no character). The execute bithas a different semantic for directories, meaningthey can be searched.

physical address An address to which a hardwaredevice, such as a memory chip, can directly respond.Programs, including the Mach kernel, use virtualaddresses that are translated to physical addressesby mapping hardware controlled by the Mach kernel.

physical memory Electronic circuitry contained inrandom-access memory (RAM) chips, used totemporarily hold information at execution time.Addresses in a process’s virtual memory are mappedto addresses in physical memory. See also virtualmemory.

pixel The basic logical unit of programmable coloron a computer display or in a computer image. Thephysical size of a pixel depends on the resolution ofthe display screen.

plug-in An external module of code and dataseparate from a host (such as an application,operating system, or other plug-in) that, byconforming to an interface defined by the host, canadd features to the host without needing access tothe source code of the host. Plug-ins are types ofloadable bundles. They are implemented with CoreFoundation Plug-in Services.

port (1) In Mach, a secure unidirectional channelfor communication between tasks running on asingle system. (2) In IP transport protocols, an integeridentifier used to select a receiver for an incomingpacket or to specify the sender of an outgoingpacket.

POSIX The Portable Operating System Interface. Anoperating-system interface standardization effortsupported by ISO/IEC, IEEE, and The Open Group.

PostScript A language that describes theappearance (text and graphics) of a printed page.PostScript is an industry standard for printing andimaging. Many printers contain or can be loadedwith PostScript software. PostScript handles

Glossary

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

129

Page 130: OSX Technology Overview

industry-standard, scalable typefaces in the Type 1and TrueType formats. PostScript is an output formatof Quartz.

preemption The act of interrupting a currentlyrunning task in order to give time to another task.

preemptive multitasking A type of multitasking inwhich the operating system can interrupt a currentlyrunning task in order to run another task, as needed.

process A BSD abstraction for a running program.A process’s resources include a virtual address space,threads, and file descriptors. In Mac OS X, a processis based on one Mach task and one or more Machthreads.

property list A structured, textual representationof data that uses Extensible Markup Language (XML)as the structuring medium. Elements of a propertylist represent data of certain types, such as arrays,dictionaries, and strings.

pthreads The POSIX Threads package (BSD).

Quartz The native 2D rendering API for Mac OS X.Quartz contains programmatic interfaces thatprovide high-quality graphics, compositing,translucency, and other effects for rendered content.Quartz is part of the Application Services umbrellaframework.

Quartz Extreme A technology integrated into thelower layers of Quartz that enables many graphicsoperations to be offloaded to hardware. Thisoffloading of work to a graphics processor unit (GPU)provides tremendous acceleration forgraphics-intensive applications. This technology isenabled automatically by Quartz and OpenGL onsupported hardware.

QuickTime Apple’s multimedia authoring andrendering technology. QuickTime lets you importand export media files, create new audio and videocontent, modify existing content, and play backcontent.

RAM Random-access memory. Memory that amicroprocessor can either read or write to.

raster graphics Digital images created or captured(for example, by scanning in a photo) as a set ofsamples of a given space. A raster is a grid of x-axis(horizontal) and y-axis (vertical) coordinates on adisplay space. (Three-dimensional images also havea z coordinate.) A raster image identifies themonochrome or color value with which to illuminateeach of these coordinates. The raster image issometimes referred to as a bitmap because itcontains information that is directly mapped to thedisplay grid. A raster image is usually difficult tomodify without loss of information. Examples ofraster-image file types are BMP, TIFF, GIF, and JPEGfiles. See also vector graphics.

real time In reference to operating systems, aguarantee of a certain capability within a specifiedtime constraint, thus permitting predictable,time-critical behavior. If the user defines or initiatesan event and the event occurs instantaneously, thecomputer is said to be operating in real time.Real-time support is especially important formultimedia applications.

reentrant The ability of code to process multipleinterleaved requests for service nearlysimultaneously. For example, a reentrant functioncan begin responding to one call, be interrupted byother calls, and complete them all with the sameresults as if the function had received and executedeach call serially.

Glossary

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

130

Page 131: OSX Technology Overview

resolution The number of pixels (individual pointsof color) contained on a display monitor, expressedin terms of the number of pixels on the horizontalaxis and the number on the vertical axis. Thesharpness of the image on a display depends on theresolution and the size of the monitor. The sameresolution will be sharper on a smaller monitor andgradually lose sharpness on larger monitors becausethe same number of pixels are being spread out overa larger area.

resource Anything used by executable code,especially by applications. Resources include images,sounds, icons, localized strings, archived userinterface objects, and various other things. Mac OSX supports both Resource Manager–style resourcesand “per-file” resources. Localized and nonlocalizedresources are put in specific places within bundles.

retained window A window with an offscreenbuffer for screen pixel values. Images are renderedinto the buffer for any portions of the window thataren’t visible onscreen.

role An identifier of an application’s relation to adocument type. There are five roles: Editor (readsand modifies), Viewer (can only read), Print (can onlyprint), Shell (provides runtime services), and None(declares information about type). You specifydocument roles in an application’s informationproperty list.

ROM Read-only memory, that is, memory thatcannot be written to.

run loop The fundamental mechanism for eventmonitoring in Mac OS X. A run loop registers inputsources such as sockets, Mach ports, and pipes fora thread; it also enables the delivery of eventsthrough these sources. In addition to registeringsources, run loops can also register timers andobservers. There is exactly one run loop per thread.

runtime The period of time during which a programis being executed, as opposed to compile time orload time. Can also refer to the runtime environment,which designates the set of conventions thatarbitrate how software is generated into executablecode, how code is mapped into memory, and howfunctions call one another.

Safari Apple’s web browser. Safari is the defaultweb browser that ships with Mac OS X.

scheduling The determination of when eachprocess or task runs, including assignment of starttimes.

SCM Repository Source Code ManagementRepositories. A code database used to enable thecollaborative development of large projects bymultiple engineers. SCM repositories are managedby specific tools (such as CVS and Subversion), whichmanage the repository and handle check-ins andcheck-outs of code resources by engineers.

SCSI Small Computer Systems Interface. A standardconnector and communications protocol used forconnecting devices such as disk drives to computers.

script A series of statements, written in a scriptinglanguage such as AppleScript or Perl, that instructan application or the operating system to performvarious operations. Interpreter programs translatescripts.

SDK Software Development Kit. A set of frameworks,tools, and other resources for developingapplications and other software for a specific versionof a platform such as Mac OS X or iOS.

semaphore A programming technique forcoordinating activities in which multiple processescompete for the same kernel resources. Semaphoresare commonly used to share a common memory

Glossary

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

131

Page 132: OSX Technology Overview

space and to share access to files. Semaphores areone of the techniques for interprocesscommunication in BSD.

server A process that provides services to otherprocesses (clients) in the same or other computers.

Shark A tool for analyzing a running (or static)application that returns metrics to help you identifypotential performance bottlenecks.

sheet A dialog associated with a specific window.Sheets appear to slide out from underneath thewindow title and float above the window.

shell An interactive programming languageinterpreter that runs in a Terminal window. Mac OSX includes several different shells, each with aspecialized syntax for executing commands andwriting structured programs, called shell scripts.

SMP Symmetric multiprocessing. A feature of anoperating system in which two or more processorsare managed by one kernel, sharing the samememory and having equal access to I/O devices, andin which any task, including kernel tasks, can run onany processor.

socket (1) In BSD-derived systems, a socket refersto different entities in user and kernel operations.For a user process, a socket is a file descriptor thathas been allocated using socket(2). For the kernel,a socket is the data structure that is allocated whenthe kernel’s implementation of the socket(2) callis made. (2) In AppleTalk protocols, a socket servesthe same purpose as a “port” in IP transportprotocols.

spool To send files to a device or program (calleda spooler or daemon) that puts them in a queue forlater processing. The print spooler controls outputof jobs to a printer. Other devices, such as plottersand input devices, can also have spoolers.

subframework A public framework that packagesa specific Apple technology and is part of anumbrella framework. Through various mechanisms,Apple prevents or discourages developers fromincluding or directly linking with subframeworks.See also umbrella framework.

symbolic link A lightweight reference to files andfolders in UFS file systems. A symbolic link allowsmultiple references to files and folders withoutrequiring multiple copies of these items. Symboliclinks are fragile because if what they refer to movessomewhere else in the file system, the link breaks.However, they are useful in cases where the locationof the referenced file or folder will not change. Seealso alias.

system framework A framework developed byApple and installed in the file-system location forsystem software.

task A Mach abstraction, consisting of a virtualaddress space and a port name space. A task itselfperforms no computation; rather, it is the context inwhich threads run. See also thread.

TCP/IP Transmission Control Protocol/InternetProtocol. An industry-standard protocol used todeliver messages between computers over thenetwork. TCP/IP support is included in Mac OS X.

thread In Mach, the unit of CPU utilization. A threadconsists of a program counter, a set of registers, anda stack pointer. See also task.

thread-safe code Code that can be used safely byseveral threads simultaneously.

timer A kernel resource that triggers an event at aspecified interval. The event can occur only once orcan be recurring. Timers are one of the input sourcesfor run loops. Timers are also implemented at higherlevels of the system, such NSTimer in Cocoa.

Glossary

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

132

Page 133: OSX Technology Overview

transformation An alteration to a coordinate systemthat defines a new coordinate system. Standardtransformations include rotation, scaling, andtranslation. A transformation is represented by amatrix.

UDF Universal Disk Format. The file-system formatused in DVD disks.

UFS UNIX file system. An industry-standardfile-system format used in UNIX-like operatingsystems such as BSD. UFS in Mac OS X is a derivativeof 4.4BSD UFS. Its disk layout is not compatible withother BSD UFS implementations.

umbrella framework A system framework thatincludes and links with constituent subframeworksand other public frameworks. An umbrellaframework “contains” the system software definingan application environment or a layer of systemsoftware. See also subframework.

Unicode A 16-bit character set that assigns uniquecharacter codes to characters in a wide range oflanguages. In contrast to ASCII, which defines 128distinct characters typically represented in 8 bits,Unicode comprises 65536 distinct characters thatrepresent the unique characters used in manylanguages.

vector graphics The creation of digital imagesthrough a sequence of commands or mathematicalstatements that place lines and shapes in atwo-dimensional or three-dimensional space. Oneadvantage of vector graphics over bitmap graphics(or raster graphics) is that any element of the picturecan be changed at any time because each elementis stored as an independent object. Anotheradvantage of vector graphics is that the resultingimage file is typically smaller than a bitmap file

containing the same image. Examples ofvector-image file types are PDF, encapsulatedPostScript (EPS), and SVG. See also raster graphics.

versioning With frameworks, schemes to implementbackward and forward compatibility of frameworks.Versioning information is written into a framework’sdynamic shared library and is also reflected in theinternal structure of a framework. See also majorversion; minor version.

VFS Virtual File System. A set of standard internalfile-system interfaces and utilities that facilitatesupport for additional file systems. VFS provides aninfrastructure for file systems built into the kernel.

virtual address A memory address that is usableby software. Each task has its own range of virtualaddresses, which begins at address zero. The Machoperating system makes the CPU hardware mapthese addresses onto physical memory only whennecessary, using disk memory at other times. Seealso physical address.

virtual machine (VM) A simulated computer in thatit runs on a host computer but behaves as if it werea separate computer.

virtual memory The use of a disk partition or a fileon disk to provide the facilities usually provided byRAM. The virtual-memory manager in Mac OS Xprovides either a 32-bit or 64-bit protected addressspace for each task (depending on the options usedto build the task) and facilitates efficient sharing ofthat address space.

VoiceOver A spoken user interface technology forvisually impaired users.

Glossary

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

133

Page 134: OSX Technology Overview

volume A storage device or a portion of a storagedevice that is formatted to contain folders and filesof a particular file system. A hard disk, for example,may be divided into several volumes (also known aspartitions).

volume format The structure of file and folder(directory) information on a hard disk, a partition ofa hard disk, a CD-ROM, or some other volumemounted on a computer system. Volume formatscan specify such things as multiple forks (HFS andHFS+), symbolic and hard links (UFS), case sensitivityof filenames, and maximum length of filenames. Seealso file system.

widget An HTML-based program that runs in theDashboard layer of the system.

window server A systemwide process that isresponsible for rudimentary screen displays, windowcompositing and management, event routing, andcursor management. It coordinates low-levelwindowing behavior and enforces a fundamentaluniformity in what appears on the screen.

workflow In the Automator application andframework, a workflow combines multiple actionsin a particular sequence; when the workflowexecutes, data is piped from one action to the nextuntil the desired result is achieved. See action.

Xcode An integrated development environment(IDE) for creating Mac OS X software. Xcodeincorporates compiler, debugger, linker, and textediting tools into a single package to streamline thedevelopment process.

Glossary

2012-01-09 | © 2004, 2012 Apple Inc. All Rights Reserved.

134

Page 135: OSX Technology Overview

Apple Inc.© 2004, 2012 Apple Inc.All rights reserved.

No part of this publication may be reproduced,stored in a retrieval system, or transmitted, in anyform or by any means, mechanical, electronic,photocopying, recording, or otherwise, withoutprior written permission of Apple Inc., with thefollowing exceptions: Any person is herebyauthorized to store documentation on a singlecomputer for personal use only and to printcopies of documentation for personal useprovided that the documentation containsApple’s copyright notice.

The Apple logo is a trademark of Apple Inc.

No licenses, express or implied, are granted withrespect to any of the technology described in thisdocument. Apple retains all intellectual propertyrights associated with the technology describedin this document. This document is intended toassist application developers to developapplications only for Apple-labeled computers.

Apple Inc.1 Infinite LoopCupertino, CA 95014408-996-1010

.Mac is a registered service mark of Apple Inc.

App Store is a service mark of Apple Inc.

iCloud is a registered service mark of Apple Inc.

iTunes Store is a registered service mark of AppleInc.

Mac App Store is a service mark of Apple Inc.

MobileMe is a service mark of Apple Inc.

Apple, the Apple logo, AirPort, AirPort Extreme,AppleScript, AppleShare, AppleTalk, Aqua,Bonjour, Carbon, Cocoa, Cocoa Touch, ColorSync,Dashcode, eMac, Exposé, Final Cut, Final Cut Pro,Finder, FireWire, iBook, iCal, iChat, Instruments,iPhoto, iTunes, Keychain, Leopard, Mac, Mac OS,Macintosh, Numbers, Objective-C, OS X, Pages,Quartz, QuickDraw, QuickTime, Safari, Sand, SnowLeopard, Spaces, Spotlight, Time Machine,TrueType, WebObjects, Xcode, and Xgrid aretrademarks of Apple Inc., registered in the UnitedStates and other countries.

OpenCL and Velocity Engine are trademarks ofApple Inc.

IOS is a trademark or registered trademark ofCisco in the U.S. and other countries and is usedunder license.

Intel and Intel Core are registered trademarks ofIntel Corporation or its subsidiaries in the UnitedStates and other countries.

Java is a registered trademark of Oracle and/orits affiliates.

OpenGL is a registered trademark of SiliconGraphics, Inc.

PowerPC and and the PowerPC logo aretrademarks of International Business MachinesCorporation, used under license therefrom.

UNIX is a registered trademark of The OpenGroup.

Even though Apple has reviewed this document,APPLE MAKES NO WARRANTY OR REPRESENTATION,EITHER EXPRESS OR IMPLIED, WITH RESPECT TO THISDOCUMENT, ITS QUALITY, ACCURACY,MERCHANTABILITY, OR FITNESS FOR A PARTICULARPURPOSE. AS A RESULT, THIS DOCUMENT IS PROVIDED“AS IS,” AND YOU, THE READER, ARE ASSUMING THEENTIRE RISK AS TO ITS QUALITY AND ACCURACY.

IN NO EVENT WILL APPLE BE LIABLE FOR DIRECT,INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIALDAMAGES RESULTING FROM ANY DEFECT ORINACCURACY IN THIS DOCUMENT, even if advised ofthe possibility of such damages.

THE WARRANTY AND REMEDIES SET FORTH ABOVEARE EXCLUSIVE AND IN LIEU OF ALL OTHERS, ORALOR WRITTEN, EXPRESS OR IMPLIED. No Apple dealer,agent, or employee is authorized to make anymodification, extension, or addition to this warranty.

Some states do not allow the exclusion or limitationof implied warranties or liability for incidental orconsequential damages, so the above limitation orexclusion may not apply to you. This warranty givesyou specific legal rights, and you may also have otherrights which vary from state to state.