osx technology overview

131
Mac OS X Technology Overview General 2011-04-30

Upload: rafael-fernandes

Post on 16-Oct-2014

821 views

Category:

Documents


6 download

TRANSCRIPT

Page 1: OSX Technology Overview

Mac OS X Technology OverviewGeneral

2011-04-30

Page 2: OSX Technology Overview

Apple Inc.© 2004, 2011 Apple Inc.All rights reserved.

No part of this publication may be reproduced,stored in a retrieval system, or transmitted, inany form or by any means, mechanical,electronic, photocopying, recording, orotherwise, without prior written permission ofApple Inc., with the following exceptions: Anyperson is hereby authorized to storedocumentation on a single computer forpersonal use only and to print copies ofdocumentation for personal use provided thatthe documentation contains Apple’s copyrightnotice.

The Apple logo is a trademark of Apple Inc.

No licenses, express or implied, are grantedwith respect to any of the technology describedin this document. Apple retains all intellectualproperty rights associated with the technologydescribed in this document. This document isintended to assist application developers todevelop applications only for Apple-labeledcomputers.

Apple Inc.1 Infinite LoopCupertino, CA 95014408-996-1010

.Mac is a registered 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,Pages, Quartz, QuickDraw, QuickTime, Safari,Sand, Snow Leopard, Spaces, Spotlight, TimeMachine, TrueType, Velocity Engine,WebObjects, Xcode, and Xgrid are trademarksof Apple Inc., registered in the United Statesand other countries.

OpenCL is a trademark of Apple 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 trademarksof Intel Corporation or its subsidiaries in theUnited States 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 TOTHIS DOCUMENT, ITS QUALITY, ACCURACY,MERCHANTABILITY, OR FITNESS FOR A PARTICULARPURPOSE. AS A RESULT, THIS DOCUMENT ISPROVIDED “AS IS,” AND YOU, THE READER, AREASSUMING THE ENTIRE RISK AS TO ITS QUALITYAND ACCURACY.

IN NO EVENT WILL APPLE BE LIABLE FOR DIRECT,INDIRECT, SPECIAL, INCIDENTAL, ORCONSEQUENTIAL DAMAGES RESULTING FROM ANYDEFECT OR INACCURACY IN THIS DOCUMENT, evenif advised of the possibility of such damages.

THE WARRANTY AND REMEDIES SET FORTH ABOVEARE EXCLUSIVE AND IN LIEU OF ALL OTHERS, ORALOR WRITTEN, EXPRESS OR IMPLIED. No Appledealer, agent, or employee is authorized to makeany modification, extension, or addition to thiswarranty.

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 haveother rights which vary from state to state.

Page 3: OSX Technology Overview

Contents

Introduction About the Technologies for Developing Mac OS X Software 11

At a Glance 11Mac OS X Has a Layered Architecture With Key Technologies in Each Layer 11You Can Create Many Different Kinds of Software for Mac OS X 13When Porting a Cocoa Touch Application, Be Aware of the Similarities and Differences in API13

Tools to Help You Develop Software for Mac OS X 14Information to Help You Develop Software for Mac OS X 14

Chapter 1 Software Product Types 17

Applications 17Frameworks 17Plug-ins 18

Address Book Action Plug-Ins 18Application Plug-Ins 18Automator Plug-Ins 18Contextual Menu Plug-Ins 19Core Audio Plug-Ins 19Image Units 19Input Method Components 19Metadata Importers 20Safari Plug-ins 20

Safari Extensions 20Dashboard Widgets 21Agent Applications 21Screen Savers 21

Slideshows 22Programmatic Screen Savers 22

Services 22Preference Panes 23Web Content 23

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

Mail Stationery 24Command-Line Tools 24Launch Items and Daemons 24Scripts 25Scripting Additions for AppleScript 26Kernel Extensions 26Device Drivers 27

32011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

Page 4: OSX Technology Overview

Chapter 2 Cocoa Application Layer 29

High-Level Features 29Resume 29Automatic and Sudden Termination of Applications 30User Interface Preservation 30Auto Save 30Full-Screen Mode 31Cocoa Autolayout 31Software Configuration 32Accessibility 32AppleScript 33Spotlight 33Ink Services 34

Frameworks 34Cocoa Umbrella Framework 34AppKit 35Preference Pane 35Screen Saver 36Security Interface 36

Chapter 3 Media Layer 37

Supported Media Formats 37Graphics Technologies 38

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

Audio Technologies 41Video Technologies 41Media Layer Frameworks 42

Application Services Umbrella Framework 42AV Foundation 44ColorSync 44Core Audio 45Instant Messaging 46OpenAL 46OpenGL 46Quartz 47Quartz Core 48QuickTime Kit 50Other Media Layer Frameworks 50

42011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CONTENTS

Page 5: OSX Technology Overview

Chapter 4 Core Services Layer 53

High-Level Features 53File Coordination 53Bundles and Packages 54Internationalization and Localization 54Blocks 55Grand Central Dispatch 55Bonjour 56Security Services 56Speech Technologies 57Identity Services 57Time Machine Support 57Keychain Services 57XML Parsing 58SQLite Database 58Distributed Notifications 58

Core Service Frameworks 59Core Services Umbrella Framework 59Address Book 60Automator 60Core Data 60Foundation and Core Foundation 61Quick Look 62Sync Services 63WebKit 63Other Frameworks in the Core Services Layer 63

Chapter 5 Core OS Layer 65

High-Level Features 65Application Sandboxing and Privilege Separation 65Code Signing 66

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

Chapter 6 Kernel and Device Drivers Layer 69

High-Level Features 69XPC Interprocess Communication and Services 69Caching API 70

The Kernel 70

52011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CONTENTS

Page 6: OSX Technology Overview

Mach 7064-Bit Kernel 71Device-Driver Support 72Network Kernel Extensions 72

BSD 72IPC and Notification Mechanisms 73Network Support 74File-System Support 77Security 78Scripting Support 79Threading Support 79X11 80Software Development Support 80

Chapter 7 Migrating from Cocoa Touch 85

General Migration Notes 85Migrating Your Data Model 85Managing Memory 86Migrating Your User Interface 86Migrating Your Controller Layer 87Application Types 88Migration Guidelines 88

Differences Between the UIKit and AppKit Frameworks 88User Events and Event Handling 89Windows 89Menus 90Documents 90Views and Controls 91File System 91Graphics, Drawing, and Printing 92Text 93Table Views 93Other Interface Differences 94

Foundation Framework Differences 95Differences in the Audio and Video Frameworks 96Differences in Other Frameworks Common to Both Platforms 97

Appendix A Mac OS X Frameworks 99

System Frameworks 99Accelerate Framework 106Application Services Framework 106Automator Framework 107Carbon Framework 107Core Services Framework 108

62011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CONTENTS

Page 7: OSX Technology Overview

IMCore Framework 108Quartz Framework 109WebKit Framework 109

Xcode Frameworks 109System Libraries 110

Document Revision History 111

Glossary 113

Index 125

72011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CONTENTS

Page 8: OSX Technology Overview

82011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CONTENTS

Page 9: OSX Technology Overview

Figures and Tables

Introduction About the Technologies for Developing Mac OS X Software 11

Figure I-1 Layers of Mac OS X 12

Chapter 1 Software Product Types 17

Table 1-1 Scripting language summary 25

Chapter 3 Media Layer 37

Table 3-1 Partial list of formats supported in Mac OS X 37Table 3-2 Features of the Mac OS X printing system 40Table 3-3 Quartz 2D technical specifications 43

Chapter 6 Kernel and Device Drivers Layer 69

Table 6-1 Network protocols 75Table 6-2 Network technology support 76Table 6-3 Supported local volume formats 77Table 6-4 Supported network file-sharing protocols 78

Chapter 7 Migrating from Cocoa Touch 85

Table 7-1 Comparison of graphics, drawing, and printing APIs 92Table 7-2 Differences between UIKit and AppKit in interface technologies 94Table 7-3 Foundation technologies available in Mac OS X but not in iOS 96Table 7-4 Differences in frameworks common to iOS and Mac OS X 97

Appendix A Mac OS X Frameworks 99

Table A-1 System frameworks 99Table A-2 Subframeworks of the Accelerate framework 106Table A-3 Subframeworks of the Application Services framework 106Table A-4 Subframeworks of the Automator framework 107Table A-5 Subframeworks of the Carbon framework 107Table A-6 Subframeworks of the Core Services framework 108Table A-7 Subframeworks of the IMCore framework 108Table A-8 Subframeworks of the Quartz framework 109Table A-9 Subframeworks of the WebKit framework 109Table A-10 Xcode frameworks 110

92011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

Page 10: OSX Technology Overview

102011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

FIGURES AND TABLES

Page 11: OSX Technology Overview

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

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 EachLayer

You 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 servicesand technologies that build on (or complement) the layers below. Figure I-1 provides a graphical view of thislayered approach.

At a Glance 112011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

INTRODUCTION

About the Technologies for Developing MacOS X Software

Page 12: OSX Technology Overview

Figure I-1 Layers of Mac OS X

Kernel and Device Drivers

Core OS

Core Services

Media

Cocoa (Application)

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 application behaviors. Whendeveloping a Cocoa application, you should always use the highest-level programming interface that meetsthe goals of your application. The layers (starting from the bottom) are:

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

Note: The term Cocoa in this book primarily refers to this layer of technology. In other Apple technicaldocuments, however, Cocoa frequently refers to all programmatic interfaces that you might use todevelop an application, regardless of system layer.

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

● 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. Itprovides services for accessing information about network users and resources, for determining thereachability of remote hosts, and for enabling access to devices and services on a network. It also publishesinterfaces for 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.

12 At a Glance2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

INTRODUCTION

About the Technologies for Developing Mac OS X Software

Page 13: OSX Technology Overview

Relevant Chapters: “Cocoa Application Layer” (page 29), “Media Layer” (page 37), “Core Services Layer” (page53), “Core OS Layer” (page 65), “Kernel and Device Drivers Layer” (page 69)

You Can Create Many Different Kinds of Software for Mac OS X

Using the developer tools and system frameworks, you can create a wide variety of software for Mac OS X,including the following:

● Applications. There are two basic application variants: document-based applications and applicationswith a single main window. To your basic application, you can add other system technologies whoseroles range from managing parts of your application to providing add-on features.

● Frameworks and libraries. You can make frameworks, dynamically shared libraries, and static librariesfor code sharing among applications.

● 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.

● Application plug-ins and loadable bundles. You can create bundles containing code and resourcesthat applications can dynamically load at runtime. In addition, you can create Automator actions andplug-ins for the Address Book, Installer, and Interface Builder applications.

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

Relevant Chapter: “Software Product Types” (page 17)

When Porting a Cocoa Touch Application, Be Aware of the Similaritiesand Differences in API

The technology stacks on which Cocoa and Cocoa Touch applications are based have many similarities. Somesystem frameworks are identical (or nearly identical) in each platform, including Foundation, Core Data, andAV Foundation. This commonality of API makes some migration tasks—for example, porting the data modelof your Cocoa Touch application—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 offeredby these frameworks are considerable. Consequently, you need to reimplement the view and controller layersof your Cocoa Touch application.

At a Glance 132011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

INTRODUCTION

About the Technologies for Developing Mac OS X Software

Page 14: OSX Technology Overview

Relevant Chapter: “Migrating from Cocoa Touch” (page 85)

Tools to Help You Develop Software for Mac OS X

Apple 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 sourcefiles, compile and debug your code, view documentation, and build all manner of software products. Thetools suite also includes compiler and performance tools, header files, sample code, and documentation forApple technologies. You can download the Xcode tools from the Member Center of the Apple DeveloperConnection (ADC) website (http://connect.apple.com/) or from the Developer Tools webpage (http://devel-oper.apple.com/technologies/tools/). Registration is required but free.

Note: Xcode 4.0, introduced alongside Mac OS X version 10.7 (v10.7), is a completely redesigned version ofXcode with 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.

Information to Help You Develop Software for Mac OS X

The Mac OS X Developer Reference Library contains the documentation, sample code, tutorials, and otherinformation you need to write Mac OS X applications. 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 Startedand Required Reading documents. If you are new to software development for Mac OS X, browse throughthese documents to familiarize yourself with the architectures, conventions, tools, and basic techniques fordeveloping software.

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

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

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

14 Tools to Help You Develop Software for Mac OS X2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

INTRODUCTION

About the Technologies for Developing Mac OS X Software

Page 15: OSX Technology Overview

● BSD. Berkeley Software Distribution (BSD) is an essential UNIX-based part of the operating system’skernel environment. Several excellent books on BSD and UNIX are available in bookstores. But you canalso find additional information on any of the websites for BSD variants—for example, the FreeBSDproject at http://www.freebsd.org.

● Third-party books. Several excellent books on Mac OS X application development can be found onlineand in the technical sections of book stores.

Information to Help You Develop Software for Mac OS X 152011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

INTRODUCTION

About the Technologies for Developing Mac OS X Software

Page 16: OSX Technology Overview

16 Information to Help You Develop Software for Mac OS X2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

INTRODUCTION

About the Technologies for Developing Mac OS X Software

Page 17: OSX Technology Overview

Applications are the most common type of software in Mac OS X. But there are many other types of softwarethat you can create. The following sections introduce the types of software you can create in Mac OS X andwhen you might consider doing so.

Applications

Applications are by far the predominant type of software created for Mac OS X, or for any platform. You useCocoa to build new applications for Mac OS X. See “Cocoa Application Layer” (page 29) for more information.

Frameworks

A 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 stringsfor a dynamic shared library would normally be installed in a separate location from the library itself, in aframework they are integral to the framework bundle. Frameworks also have a version control mechanismthat makes it possible 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 applications.

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 distribution of Applesoftware. The creation of umbrella frameworks by third-party developers is not recommended.

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.

Applications 172011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 1

Software Product Types

Page 18: OSX Technology Overview

Plug-ins

Plug-ins are the standard way to extend many applications and system behaviors. Plug-ins are bundles whosecode is loaded dynamically into the runtime of an application. Because they are loaded dynamically, theycan be added and removed by the user.

There are many opportunities for developing plug-ins for Mac OS X. Developers can create plug-ins forthird-party applications or for Mac OS X itself. Some parts of Mac OS X define plug-in interfaces for extendingthe basic system behavior. The following sections list many of these opportunities for developers, althoughother software types may also use the plug-in model. (Pointers to relevant technical documents are givenfor each type of plug-in.)

Address Book Action Plug-Ins

An 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 forMac OS X.

Application Plug-Ins

Several 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 orfor other applications that support a plug-in model. For information about developing plug-ins for Appleapplications, visit the ADC website at http://developer.apple.com/.

Automator Plug-Ins

Automator is a workflow-based application that lets users assemble complex scripts graphically using apalette of available actions. You can extend the default set of actions by creating Automator plug-ins tosupport new actions. Because they can be written in AppleScript or Objective-C, you can write plug-ins foryour own application’s features or for the features of other scriptable applications.

If you are developing an application, you should think about providing Automator plug-ins for yourapplication’s most common tasks. AppleScript is one of the easiest ways for you to create Automator plug-insbecause it can take advantage of existing code in your application. If you are an Objective-C developer, youcan also use that language to create plug-ins.

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

18 Plug-ins2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 1

Software Product Types

Page 19: OSX Technology Overview

Contextual Menu Plug-Ins

The 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 application. 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-ins. For information on the Carbon Menu Managerfunctions you need to implement, see Menu Manager Reference.

Core Audio Plug-Ins

The Core Audio system supports plug-ins for manipulating audio streams during most processing stages.You can use plug-ins to generate, process, receive, or otherwise manipulate an audio stream. You can alsocreate plug-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 Units

You 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 Components

An 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 usesto process the input data. For example, you might use a background application to record the input keystrokesand compute the list of potential complex characters that those keystrokes can create.

Plug-ins 192011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 1

Software Product Types

Page 20: OSX Technology Overview

In Mac OS X v10.5 and later, you can create input methods using the Input Method Kit(InputMethodKit.framework). For information on how to use this framework, see Input Method KitFramework Reference.

Metadata Importers

You can create a metadata importer for your application’s file formats. Metadata importers are used bySpotlight to gather information about the user’s files and build a systemwide index. This index is then usedfor advanced searching based on more user-friendly information.

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

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

Safari Plug-ins

Safari 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 not compatiblewith 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 Extensions

With 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 unwantedsites, and create contextual menu items. Extensions let you inject scripts and style sheets into pages of webcontent.

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 Extensions Development Guide in the Safari DeveloperLibrary.

20 Safari Extensions2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 1

Software Product Types

Page 21: OSX Technology Overview

Dashboard Widgets

Dashboard is****** a lightweight desktop layer for running widgets. Widgets are lightweight web applicationsthat display information a user might use occasionally. You could write widgets to track stock quotes, viewthe current time, or access key features of a frequently used application. Widgets reside in the Dashboardlayer, which is activated by the user and comes into the foreground in a manner similar to Exposé. Mac OSX comes with several standard widgets, including a calculator, clock, and iTunes controller.

Creating widgets is simpler than creating most applications because widgets are effectively HTML-basedapplications with optional JavaScript code to provide dynamic behavior. Dashboard uses WebKit to providethe environment for displaying the HTML and running the JavaScript code. Your widgets can take advantageof several extensions provided by that environment, including a way to render content using Quartz-likeJavaScript functions. In Mac OS X v10.5 and later, you can create widgets using the Dashcode application.

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

Agent Applications

An 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 application. Agents candisplay panels occasionally or come to the foreground to interact with the user if necessary. User interactionsshould always be brief and have a specific goal, such as setting preferences or requesting a piece of neededinformation.

An agent may be launched by the user but is more likely to be launched by the system or another application.As a result, agents do not show up in the Dock or the window displayed by the Force Quit menu command.Agents also do not have a menu bar for choosing commands. User manipulation of an agent typically occursthrough dialogs or contextual menus in the agent user interface. For example, the iChat application uses anagent to communicate with the chat server and notify the user of incoming chat requests. The Dock is anotheragent program that is launched by the system for the benefit of the user.

The way to create an agent application is to create a bundled application and include the LSUIElement keyin its Info.plist file. The LSUIElement key notifies the Dock that it should treat the application as anagent when double-clicked by the user. For more information on using this key, see Runtime ConfigurationGuidelines.

Screen Savers

Screen 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.

Dashboard Widgets 212011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 1

Software Product Types

Page 22: OSX Technology Overview

Slideshows

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

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 Savers

A programmatic screen saver is one that continuously generates content to appear on the screen. You canuse this type of screen saver to create animations or to create a screen saver with user-configurable options.The bundle for a programmatic screen saver ends with the .saver extension.

You create programmatic screen savers using Cocoa and the Objective-C language. Specifically, you createa custom subclass of ScreenSaverView that provides the interface for displaying the screen saver contentand options. 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.

Services

Services are not separate programs that you write; instead, they are features exported by your applicationfor the benefit of other applications. Services let you share the resources and capabilities of your applicationwith other applications in the system.

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

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

22 Services2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 1

Software Product Types

Page 23: OSX Technology Overview

Preference Panes

Preference 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. Applicationdevelopers can also take advantage of these plug-ins to manage per-user application preferences; however,most applications manage preferences using the code provided by the application environment.

You might need to create preference panes if you create:

● Hardware devices that are user-configurable

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

If you are an application developer, you might want to reuse preference panes intended for the SystemPreferences application or use the same model to implement your application 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 Content

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

In addition to “Identity Services” (page 57) and “Dashboard Widgets” (page 21), 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 Websites

Mac OS X provides support for creating and testing dynamic content in web pages. If you are developingCGI-based web applications, you can create websites using a variety of scripting technologies, including Perland the PHP Hypertext Preprocessor. A complete list of scripting technologies is provided in “Scripts” (page25). You can also create and deploy more complex web applications using JBoss, Tomcat, and WebObjects.To deploy your webpages, use the built-in Apache web server.

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

SOAP, XML-RPC, and Web Services

The 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.

Preference Panes 232011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 1

Software Product Types

Page 24: OSX Technology Overview

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 aURL, and publish the message format your script supports.

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 Stationery

The Mail application in Mac OS X v10.5 and later supports the creation of email messages using templates.Templates provide the user with prebuilt email messages that can be customized quickly before being sent.Because templates are HTML-based, they can incorporate images and advanced formatting to give the user’semail a much more stylish 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 isthen stored in the Mail application’s stationery directory. The HTML page and images define the content ofthe email message and can include drop zones for custom user content. The property list file provides Mailwith information 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 Tools

Command-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 applications. Instead,they run from the command-line environment of the Terminal application. Command-line tools require lessexplicit knowledge of the system to develop and because of that are often simpler to write than many othertypes of applications. However, command-line tools usually serve a more technically savvy crowd who arefamiliar with the conventions and syntax of the command-line interface.

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

Launch Items and Daemons

Launch 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 clientrequests. You typically use launch items to launch daemons or perform periodic maintenance tasks, such aschecking the hard drive for corrupted information.

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 thatuser. Launch items are not user-configurable.

24 Mail Stationery2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 1

Software Product Types

Page 25: OSX Technology Overview

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.

Scripts

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

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

Table 1-1 Scripting language summary

DescriptionLanguage

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

AppleScript

A Bourne-compatible shell script language used to build programs on UNIX-based systems.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

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

Python

A general-purpose, object-oriented scripting language implemented for many platforms. Seehttp://www.ruby-lang.org/ for more information. In Mac OS X v10.5 and later, you can alsouse Ruby with the Cocoa scripting bridge; see Ruby and Python Programming Topics for MacOS X.

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. Itis often used to create graphical interfaces for scripts. See http://www.tcl.tk/ for moreinformation.

Tcl

Scripts 252011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 1

Software Product Types

Page 26: OSX Technology Overview

DescriptionLanguage

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 AppleScript

A 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 thosefeatures and make them available to all programs. For example, one of the built-in scripting additions extendsthe basic file-handling commands to support the reading and writing of file contents from an AppleScriptscript.

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

Kernel Extensions

Most 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 applications require a resource your code provides. For example, you might implementa file-system stack using a kernel extension.

● 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 27).)

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. Developersare highly encouraged to use the kernel-extension API for accessing kernel data structures.

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

26 Scripting Additions for AppleScript2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 1

Software Product Types

Page 27: OSX Technology Overview

Device Drivers

Device drivers are a special type of kernel extension that enable Mac OS X to communicate with manyhardware devices, including mice, keyboards, and FireWire drives. Device drivers communicate hardwarestatus to the system and facilitate the transfer of device-specific data to and from the hardware. Mac OS Xprovides default drivers 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 genericdrivers to 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/OKit Fundamentals.

Device Drivers 272011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 1

Software Product Types

Page 28: OSX Technology Overview

28 Device Drivers2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 1

Software Product Types

Page 29: 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 applications and their responsiveness to user actions. To contribute to the user experience,your application should support the features that help it blend into the Mac OS X ecosystem and create aseamless user experience.

Aqua is sometimes the name given the appearance and overall behavior of Mac OS X applications. Theseapplications exhibit consistent behaviors and incorporate color, depth, translucence, and complex texturesinto a visually appealing interface. If you create your application using the interfaces of the Cocoa applicationlayer, the application gets much of the Aqua appearance automatically. However, you should still ensurethat your application’s appearance and behavior conform to the user-experience guidelines stipulated byApple for applications. Read Mac OS X Human Interface Guidelines to gain invaluable insights on creatingAqua-compliant applications and on the best Mac OS X interface technologies to use.

Kernel and Device Drivers

Core OS

Core Services

Media

AppKit

Cocoa (Application)

High-Level Features

The 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.

Resume

Resume is a system-wide enhancement of the user experience, introduced in Mac OS X version 10.7, thatsupports application persistence. Users can log out or shut down the operating system, and when they nextlog into their accounts or start the system up, Mac OS X automatically relaunches the applications that werelast running and restores the windows that were last opened. If an application provides the necessary support,reopened windows have the same size and location as before; in addition, their contents are scrolled to theprevious position and their selections are restored.

High-Level Features 292011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 2

Cocoa Application Layer

Page 30: OSX Technology Overview

Application persistence requires you to implement the ancillary programmatic features of automatic andsudden application termination, user interface preservation, and Auto Save, which the following sectionsdescribe.

Automatic and Sudden Termination of Applications

Automatic application termination, a feature introduced in Mac OS X version 10.7, manages the life cycle ofapplications behind the scenes, terminating applications that are not being used and thereby reclaimingresources such as memory. With this feature, users no longer need to explicitly quit applications (althoughthey still can, if they want to). Instead, the operating system is responsible for managing application processeswith the goal of ensuring optimal system performance.

For your applications to participate in automatic termination, you must opt-in to the feature and implementthe required methods for user interface preservation and (if your application is document-based) automaticdocument saving. If your application is not document-based, your application should still save its data atappropriate intervals.

Note that automatic termination is distinct from the related feature of sudden termination, in which theoperating system immediately kills application processes when users log out, shut down the system, orperform similar operations. Applications should implement both automatic termination and suddentermination.

To learn more about automatic application termination, see “Automatic and Sudden Termination ofApplications Improve the User Experience” in Mac OS X Application Programming Guide.

User Interface Preservation

User interface preservation is a programmatic feature introduced in Mac OS X version 10.7 that saves thestate of your application’s windows and restores the windows to that state during subsequent launches ofyour application. Restored windows have the size and location on the screen as they had previously, arescrolled to the previous position, and have the previously selected item as the selection. If your applicationsupports automatic application termination, it is important that it also support user interface preservation.If you do not preserve the state of your application’s user interface, then the application launches in its defaultstate.

Although the AppKit framework handles the writing of your application’s state to disk, your application musttell it what to save. AppKit saves data not just for windows marked for preservation, but for all objects in thewindow’s view hierarchy as well as associated window controllers and document objects. When the applicationis next launched and AppKit finds preserved interface data, the framework communicates the data to aspecially designated restoration class whose role is to re-create a window and all of the critical objects requiredby the window. For more information about user interface preservation, see “User Interface Preservation” inMac OS X Application Programming Guide.

Auto Save

Starting in Mac OS X version 10.7, applications can (with the help of the operating system) automaticallysave their documents at frequent intervals. The system writes document data to disk as necessary so thatdata displayed in a document window is, in effect, always the same as the document data on disk. With the

30 High-Level Features2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 2

Cocoa Application Layer

Page 31: OSX Technology Overview

Auto Save feature, users no longer have to explicitly save documents and no longer have to worry aboutlosing unsaved changes. Applications provided by Apple have been implemented to automatically save theirdocuments.

If your application is document-based, you can acquire this automatic saving behavior by overriding methodsof NSDocument. For details about implementing automatic document saving (or Auto Save), see “AutomaticDocument Saving” in Mac OS X Application Programming Guide. If your application is not document-based,you should still save application data at key application life-cycle junctures and whenever data is entered orchanged.

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 usercan view a list of previous versions of the document that were created as the user was editing it (similar tothe list that Time Machine provides). Although users cannot change a previous version of the document,they can view it, copy and paste portions of it, and change viewing options. Although users can undo someediting actions (and thus return to previous document versions), you can mark some undo actions asdiscardable if the document is locked in some way (for example, if the version is on a locked volume).

Full-Screen Mode

Starting in Mac OS X version 10.7, you can enable full-screen mode for your applications by calling a singlemethod. Enabling full-screen support adds an Enter Full Screen menu item (with associated action method)to the View menu or, if there is no View menu, to the Window menu. When users choose this command, thecurrent application window or document window fills the entire screen. The AppKit framework providessupport for customizing the appearance and behavior of full-screen windows. For example, you can set awindow-style mask and you can implement custom animations when an applications enters and exitsfull-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 theFull-Screen Experience” in Mac OS X Application Programming Guide.

Cocoa Autolayout

Cocoa autolayout, a feature introduced in Mac OS X version 10.7, is a technology that expands and improvesthe “springs and struts” model previously used to lay out the elements of a user interface. Cocoa autolayoutis a rule-based system designed to fully implement the human interface guidelines documented in Mac OSXHuman InterfaceGuidelines. It expresses a larger class of relationships and is closer to a typical understandingof view layout than the “springs and struts” model.

In Cocoa autolayout, the entities used for layout are Objective-C objects called constraints rather thanrecordings of view-boundary relationships. This object-based model brings you a number of benefits:

● It enables localization that permits a simple swapping of strings instead of the need to revamp layouts(in most cases).

● It facilitates the mirroring of user-interface elements for right-to-left languages like Hebrew and Arabic.

● It provides better layering of responsibility between objects in the view and controller layers. View objectsoften know best about their standard size and positioning within their superview and relative to siblingviews. Controllers can override these values if something nonstandard is required.

High-Level Features 312011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 2

Cocoa Application Layer

Page 32: OSX Technology Overview

You define constraints objects through a simple language for visualizing layout of UI elements according toattributes such as leading, trailing, left, right, top, bottom, width, and height. (Leading and trailing are likeleft and right, but they flip over to mirror the constraint in a right-to-left environment like Hebrew or Arabic.)Constraint objects also have a priority level assigned to them so that constraints with higher priorities aresatisfied before constraints with lower priorities. You create a constraint object using theNSLayoutConstraint class and then, by calling methods of the NSView class, assign the object to a commonancestor of the views to which the constraint applies. You can override methods of the NSWindow and NSViewclasses to update view constraints before updating their layout and display.

For more information on this technology, see Cocoa Autolayout Release Notes.

Software Configuration

Mac 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. Applications use a specialtype of property list file, called an information property list (Info.plist) file, to communicate key attributesof the application—such as the application’s name, unique identification string, and version information—tothe system. Applications also use property list files to store user preferences or other custom configurationdata. If your application stores custom configuration data, you should consider using property list files aswell.

The advantage of property list files is that they are easy to edit and modify from outside the runtimeenvironment of your application. Mac OS X provides several tools for creating and modifying property listfiles. The Property List Editor application that comes with Xcode is the main application for editing thecontents of property lists. Xcode also provides a custom interface for editing your application’s Info.plistfile. (For information about information property list files and the keys you put in them, see RuntimeConfiguration Guidelines and Information 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,see Property List Programming Guide or Property List Programming Topics for Core Foundation.

Accessibility

Millions of people have some type of disability or special need. Federal regulations in the United Statesstipulate that computers used in government or educational settings must provide reasonable access forpeople with disabilities. Mac OS X includes built-in functionality to accommodate users with special needs.It also provides software developers with the functions they need to support accessibility in their ownapplications.

Applications that use Cocoa or modern Carbon interfaces receive significant support for accessibilityautomatically. For example, applications get 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.

● 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.

32 High-Level Features2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 2

Cocoa Application Layer

Page 33: OSX Technology Overview

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

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

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

For more information about accessibility, see Accessibility Overview.

AppleScript

Mac OS X employs AppleScript as the primary language for making applications scriptable. With AppleScript,users can write scripts that link together the services of multiple scriptable applications.

When designing new applications, you should consider AppleScript support early in the process. The key toa good design that supports AppleScript is choosing an appropriate data model for your application. Thedesign must not only serve the purposes of your application but should also make it easy for AppleScriptimplementers to manipulate your content. Once you settle on a data model, you can implement the Appleevent code needed to support scripting.

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.

Spotlight

Spotlight provides advanced search capabilities for applications. The Spotlight server gathers metadata fromdocuments and other relevant user files and incorporates that metadata into a searchable index. The Finderuses this metadata to provide users with more relevant information about their files. For example, in additionto listing the name of a JPEG file, the Finder can also list its width and height in pixels.

Application developers use Spotlight in two different ways. First, you can search for file attributes and contentusing the Spotlight search API. Second, if your application defines its own custom file formats, you shouldincorporate any appropriate metadata information in those formats and provide a Spotlight importer plug-into return that metadata to Spotlight.

Note: You should not use Spotlight for indexing and searching the general content of a file. Spotlight isintended for searching only the meta information associated with files. To search the actual contents of afile, use the Search Kit API. For more information on Search Kit, see “Other Frameworks in the Core ServicesLayer” (page 63).

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

High-Level Features 332011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 2

Cocoa Application Layer

Page 34: OSX Technology Overview

Ink Services

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

● 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 applications. Hardware developers can also use it to implementa handwriting recognition solution for a new input device. You might also use the Ink framework to implementyour own correction 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 applications, seeUsing Ink Services in Your Application.

Frameworks

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

Cocoa Umbrella Framework

The Cocoa umbrella framework (Cocoa.framework) imports the core Objective-C frameworks for applicationdevelopment: 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 35) for a summary of AppKit features and classes.

● 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 ofFoundation classes.

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

● Core Data (CoreData.framework). The classes of the Core Data framework (which also resides in theCore Services layer) manage the data model of an application based on the Model-View-Controller designpattern. Although Core Data is optional for application development, it is recommended for applicationsthat deal with large data sets.

34 Frameworks2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 2

Cocoa Application Layer

Page 35: OSX Technology Overview

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

AppKit

AppKit is the key framework for Cocoa applications. The classes in the AppKit framework implement the userinterface of an application, including windows, dialogs, controls, menus, and event handling. They also handlemuch of the behavior required of a well-behaved application, including menu management, windowmanagement, document management, 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. Alarge subset of classes comprise the Cocoa text system, described in “Text, Typography, and Fonts” (page39). Other AppKit classes support document management, printing, and services such as spellchecking, help,speech, and pasteboard and drag-and-drop operations.

Applications can participate in many of the features that make the user experience of Mac OS X such anintuitive, 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. Applications can provide users with immediate and in-depth answers to questions byimplementing help tags (also called tooltips) and documentation. In addition, the Spotlight for Helpfeature makes it easier for users to locate items in complex menu. For information on adding help to aCocoa application, see Online Help.

● 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 application should avoid doing anything that might affectanother version of the application running in a different session. Multiple User Environments explainshow to implement this behavior.

The Interface Builder application (now integrated into Xcode 4) includes many objects of the AppKit frameworkin its library. This makes it possible for you to create most of your user interface (including much of its behavior)graphically rather than programatically. With the addition of Cocoa bindings and Core Data, you can alsoimplement most of the rest of your application graphically as well.

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

Preference Pane

The Preference Pane framework (PreferencePane.framework) lets you create plug-ins containing a userinterface for setting application preferences. At runtime, the System Preferences application (or the applicationitself ) can dynamically load the plug-in and present the settings interface to users. In System Preferences,each icon in its Show All view represents an individual preference pane plug-in. You typically implement

Frameworks 352011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 2

Cocoa Application Layer

Page 36: OSX Technology Overview

Preference Pane plug-ins when your application lacks its own user interface or has a very limited user interfacebut needs to be configurable. You must not only create the plug-in but the application code that reads andwrites the preference settings.

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

Screen Saver

The Screen Saver framework (ScreenSaver.framework) contains classes for creating dynamically 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.

Security Interface

The 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.

36 Frameworks2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 2

Cocoa Application Layer

Page 37: 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.

Kernel and Device Drivers

Core OS

Core Services

QuartzOpenAL OpenGLCore Text

AV Foundation Core Audio Core ImageCore Animation

Media

Cocoa (Application)

Supported Media Formats

Mac 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

Supported Media Formats 372011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 3

Media Layer

Page 38: OSX Technology Overview

Graphics Technologies

A 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 touse the standard views and controls of the AppKit framework along with prerendered images. At runtime,let the system do the work of rendering the application’s user interface. There can be situations, however,when you need 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 42).

Graphics and Drawing

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

Cocoa Drawing

The 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. Itsupports drawing in both standard and custom color spaces and it supports content manipulations usinggraphics transforms. Because it is built on top of Quartz 2D, drawing calls made from Cocoa are compositedalong with all other Quartz 2D content. You can even mix Quartz 2D drawing calls (and drawing calls fromother system graphics technologies) with Cocoa calls in your code.

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

Other Frameworks for Graphics and Drawing

Other 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, paintingwith transparency, shading, drawing of shadows, transparency layers, color management, anti-aliasedrendering, and PDF document generation. The Core Graphics framework is in the Application Servicesumbrella framework.

Quartz is at the heart of the Mac OS X graphics and windowing environment. It provides renderingsupport for 2D content and combines a rich imaging model with on-the-fly rendering, compositing, andanti-aliasing of content. It also implements the windowing system for Mac OS X and provides low-levelservices such as event routing and cursor management. (See “Core Graphics” (page 42) for moreinformation.)

● 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).

38 Graphics Technologies2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 3

Media Layer

Page 39: OSX Technology Overview

● OpenGL is an open, industry-standard technology for creating and animating real-time 2D and 3Dgraphics. 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” (page42).

Text, Typography, and Fonts

Mac OS X provides extensive support for advanced typography for Cocoa applications. With this support,your application can control the fonts, layout, typesetting, text input, and text storage when managing thedisplay and editing of text. For the most basic text requirements, you can use the text fields, text views, andother text-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 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 43).

Images

Both 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 cando other things with images using the following frameworks:

● Image Kit. A framework allows users of your application to browse, view, edit, and process images. Italso lets 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.

Graphics Technologies 392011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 3

Media Layer

Page 40: OSX Technology Overview

● 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 scanparameters.

Color Management

ColorSync is the color management system for Mac OS X. It provides essential services for fast, consistent,and accurate 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 ColorSyncManager Reference. For additional information aboutthe gamma changes introduced in Mac OS X v10.6, see “Mac OS X v10.6” in What's New In Mac OS X.

Printing

Printing support in Mac OS X is implemented through a collection of APIs and system services available toall application 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 providesapplications with a high degree of control over the user interface elements in printing dialogs. Table 3-2describes some other 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 used tohandle print spooling and other low-level features, provides the underlyingsupport 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

40 Graphics Technologies2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 3

Media Layer

Page 41: OSX Technology Overview

DescriptionFeature

PDF as a native data type lets any application easily save textual and graphicaldata 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 PostScript filesdirectly to PDF.

PostScript support

The print preview capability lets users see documents through a PDF viewerapplication prior to printing.

Print preview

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

Printer discovery

Raster printers are supported in all environments.Raster printers (support for)

Speedy spooling enables applications that use PDF to submit PDF files directlyto 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.

Audio Technologies

Mac 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 arecreating a 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 42).

Video Technologies

Whether 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.

Audio Technologies 412011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 3

Media Layer

Page 42: OSX Technology Overview

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 followinglist are ordered from highest to lowest level, with the AV Foundation framework offering the highest-levelinterfaces you can use.

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

● QuickTime Kit. Use this Objective-C framework (also called QTKit) for playing, editing, exporting, capturing,and recording 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.

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

Media Layer Frameworks

Mac 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 Framework

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

Core Graphics

The 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

42 Media Layer Frameworks2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 3

Media Layer

Page 43: OSX Technology Overview

● 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

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. Graphicscalls render in supported video hardware, freeing up the CPU for othertasks.

Quartz Extreme

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

Core Text

Introduced in Mac OS X v10.5, Core Text is a C-based API that provides you with precise control over textlayout and typography. Core Text provides a layered approach to laying out and displaying Unicode text.You can modify as much or as little of the system as suits your needs. Core Text also provides optimizedconfigurations for common scenarios, saving setup 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/O

Applications 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.

Media Layer Frameworks 432011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 3

Media Layer

Page 44: OSX Technology Overview

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 andprovider objects (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.

AV Foundation

Introduced in Mac OS X v10.7, the AV Foundation framework (AVFoundation.framework) provides servicesfor inspecting, playing, capturing, 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:

● Media asset management

● Media editing

● Movie capture

● Movie playback

● Track management

● Metadata management for media items

● Stereophonic panning

● Precise synchronization between sounds

● An Objective-C interface for determining details about sound files, such as the data format, sample rate,and number of channels

AV Foundation also includes support for audio playback and recording through its AVAudioPlayer andAVAudioRecorder classes. These classes are simple to use and are sufficient for most applications withaudio requirements.

Note: The AV Foundation framework for Mac OS X is almost identical to the same framework for iOS, whichwas introduced to that platform in iOS 2.2.

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

ColorSync

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

44 Media Layer Frameworks2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 3

Media Layer

Page 45: OSX Technology Overview

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 Audio

Core 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 Audioare:

● 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 tocommunicate with MIDI devices, to configure or customize the global state of the MIDI system, and tocreate MIDI play-through connections between MIDI sources and destinations.

Most Core Audio interfaces are C-based, providing a low-latency and flexible programming environmentthat is suitable for real-time applications. You can use Core Audio from any Mac OS X program. Some of thebenefits of 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 handlesmemory management and hardware connections. Starting in Mac OS X v10.7, you can intercept and processaudio as it proceeds through an audio queue object. This real-time, callback-based feature is known as audioqueue processing taps. This feature works for input (such as for recording) as well as output (such as for

Media Layer Frameworks 452011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 3

Media Layer

Page 46: OSX Technology Overview

playback). Audio queue processing taps let you insert audio units or other forms of audio processing, effectivelytapping into and modifying the data stream within an audio queue. You can also use this technology in asiphon mode in 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.

Instant Messaging

Mac 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.

In Mac OS X v10.5 and later, you can use the Instant Message framework to support iChat Theater. Thisfeature gives your application the 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

OpenAL

The Open Audio Library (OpenAL.framework) is a cross-platform standard API for delivering 3D audio.OpenAL lets you implement high-performance positional playback in games and other programs. Becauseit is a cross-platform standard, applications you write using OpenAL in Mac OS X can be ported to run onmany other platforms.

In Mac OS X v10.5, several features were incorporated into the existing OpenAL framework. Among thesefeatures are support for audio capture, exponential and linear distance models, location offsets, and spatialeffects such as reverb and occlusion. The Mac OS X implementation of OpenAL also supports certain CoreAudio features such as mixer sample rates.

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

OpenGL

OpenGL is an industry-wide standard for developing portable three-dimensional (3D) graphics applications.It is specifically designed for applications such as games that need a rich, robust framework for visualizingshapes in two and three dimensions. The OpenGL API is one of the most widely adopted graphics API

46 Media Layer Frameworks2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 3

Media Layer

Page 47: OSX Technology Overview

standards, which makes code written for OpenGL portable and consistent across platforms. The OpenGLframework (OpenGL.framework) in Mac OS X includes a highly optimized implementation of the OpenGLlibraries that provides high-quality graphics at a consistently high level of performance.

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 adrawing action or causes a special effect, and developers can create lists of these commands for repetitiveeffects. Although OpenGL is largely independent of the windowing characteristics of each operating system,the standard 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 andOpenGL 2.n, including the removal of the fixed-function pipeline that was the main approach to developingOpenGL 1.n applications. An OpenGL 3.2 application requires you to create your own shader strategy ratherthan assuming that a standard graphics pipeline will do everything. As a result, for simple applications youneed to write 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.

Quartz

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

Image Kit

Introduced in Mac OS X v10.5, the Image Kit framework is an Objective-C framework that makes it easy toincorporate powerful imaging services into your applications. This framework takes advantage of featuresin Quartz, Core Image, OpenGL, and Core Animation to provide an advanced and highly optimizeddevelopment path for implementing the following 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

● Browsing for Core Image filters

● Displaying custom views for Core Image filters

Media Layer Frameworks 472011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 3

Media Layer

Page 48: OSX Technology Overview

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

PDF Kit

PDF Kit is a Cocoa framework for managing and displaying PDF content directly from your application’swindows and dialogs. You can embed a PDFView object in your window and give it a PDF file to display. ThePDF view handles the rendering of the PDF content, handles copy-and-paste operations, and provides controlsfor navigating and setting the zoom level. Other classes let you get the number of pages in a PDF file, findtext, manage selections, add annotations, and specify the behavior of some graphical elements, among otheractions.

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

Quartz Composer

The 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 UI

The 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 Core

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

Core Animation

Introduced in Mac OS X v10.5, Core Animation is a set of Objective-C classes for doing sophisticated 2Drendering and animation. Using Core Animation, you can create everything from basic window content tocarousel–style user interfaces (such as Front Row’s), and achieve respectable animation performance withouthaving to tune your code using OpenGL or other low-level drawing routines. This performance is achievedusing server-side content caching, which restricts the compositing operations performed by the server toonly those parts of a view or window whose contents actually change.

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

48 Media Layer Frameworks2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 3

Media Layer

Page 49: OSX Technology Overview

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 triggersan animation that causes the child layer to fade gradually into view. You can also trigger animations explicitlyin a 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 Image

Core 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 architecturelets you expand the capabilities of Core Image through the creation of image units, which implement thedesired visual effects.

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

● Crop, composite, blur, and sharpen images

● 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

Media Layer Frameworks 492011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 3

Media Layer

Page 50: OSX Technology Overview

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, see Core ImageProgrammingGuide and Core Image Reference Collection. For information about the built-in filters in Core Image, see CoreImage Filter Reference.

QuickTime Kit

The QuickTime Kit (QTKit.framework), or QTKit, is an Objective-C framework for manipulatingQuickTime-based media. This framework lets you incorporate movie playback, movie editing, export tostandard media formats, and other QuickTime behaviors easily into your applications. The classes in thisframework open up a tremendous amount of QuickTime behavior, enabling you to use a handful of classesto implement the features you need.

In Mac OS X v10.5, support was added for capturing professional-quality audio and video content from oneor more external sources, including cameras, microphones, USB and Firewire devices, DV media devices,QuickTime streams, data files, and the screen. The input and output classes included with the frameworkprovide all of the components necessary to implement the most common use case for a media capturesystem: recording from a camera to a QuickTime file. Video capture includes frame-accurate audio/videosynchronization, plus you can preview captured content and save it to a file or stream.

Note: The QuickTime Kit framework supersedes the NSMovie and NSMovieView classes available in Cocoa.If your code uses these older classes, you should change your code to use the QuickTime Kit instead.

In Mac OS X v10.6, the QuickTime Kit framework first took advantage of QuickTime X media services to allowapplications to open movies asynchronously on supported media types. The framework also uses these mediaservices to manage most interactions with media files. In Mac OS X v10.7, the QuickTime Kit framework addsthe capability for reading movie and track metadata such as author, name, and copyright.

For information on how to use the QuickTime Kit, see QuickTime Kit Programming Guide. For referenceinformation about the QuickTime Kit classes, see QTKit Framework Reference.

Other Media Layer Frameworks

The 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-levelC interface for managing and playing audiovisual media in an application. It also defines the fundamentaltime representation used uniformly throughout AV Foundation.

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 canaccess media hardware and capture video and “muxed” (video combined with audio) streams. This APIis a replacement for the QuickTime VDig API.

For information, see Core Media Framework Reference.

50 Media Layer Frameworks2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 3

Media Layer

Page 51: OSX Technology Overview

● 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-pixelaccuracy, and hardware scalability. CoreVideo.framework was introduced in Mac OS X v10.5.

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, see Disc Recording Framework Reference and Disc RecordingUI Framework Reference.

● 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 DVDPlayback 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 imagedata itself.

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

Media Layer Frameworks 512011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 3

Media Layer

Page 52: OSX Technology Overview

52 Media Layer Frameworks2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 3

Media Layer

Page 53: 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 applications but have no direct bearing on the userinterface an application presents to users. They generally are dependent on frameworks and technologiesin the Core OS layer and 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.

Kernel and Device Drivers

Core OS

Security WebkitQuick Look Sync Services

FoundationAddress Book Core FoundationCore Data

Core Services

Media

Cocoa (Application)

High-Level Features

The following sections describe some of the key technologies available in the Core Services layer.

File Coordination

File coordination is a mechanism introduced in Mac OS X version 10.7 that serializes your application’s accessto files and directories with other processes’ access to the same files and directories. This serialized accesseliminates inconsistencies due to overlapping read and write operations. The public interface for filecoordination is declared by the NSFileCoordinator class and the NSFilePresenter protocol of theFoundation framework.

These APIs let you assert your application’s ownership of files and directories. When another process attemptsto access one of these files or directories, your application is given a chance to respond. For example, whenanother application attempts to read the contents of a document your application is editing, you can writeunsaved changes to disk before the other process is allowed to do its reading.

High-Level Features 532011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 4

Core Services Layer

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. If your application is document-based, file coordinationis largely implemented for you. File coordination is an enabling technology for automatic document savingand other features introduced in Mac OS X version 10.7. For more information on file coordination, see“Coordinating File Access With Other Processes” in Mac OS X Application Programming Guide.

Bundles and Packages

A 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.

Applications and frameworks are only two examples of bundles in Mac OS X. Plug-ins, screen savers, andpreference panes are all implemented using the bundle mechanism as well. Developers can also use bundlesfor their document 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, whichthen installs 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 Localization

Localizing your application is necessary for success in many foreign markets. Users in other countries aremuch more likely to buy your software if the text and graphics reflect their own language and culture. Beforeyou can localize an application, though, you must design it in a way that supports localization, a processcalled internationalization. Properly internationalizing an application makes it possible for your code to loadlocalized content and display it correctly.

Internationalizing an application 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”).

● 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.

54 High-Level Features2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 4

Core Services Layer

Page 55: OSX Technology Overview

Blocks

Introduced 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 Dispatch

Introduced in Mac OS X v10.6, Grand Central Dispatch (GCD) provides a simple and efficient API for achievingthe concurrent execution of code in your application. Instead of threads, GCD provides the infrastructure forexecuting any task in your application asynchronously using a dispatch queue. Dispatch queues collect yourtasks and work with the kernel to facilitate their execution on an underlying thread. A single dispatch queuecan execute tasks serially or concurrently and applications can have multiple dispatch queues executingtasks in parallel.

There are several advantages to using dispatch queues over traditional threads. One of the most importantis performance. Dispatch queues work more closely with the kernel to eliminate the normal overheadassociated with creating threads. Serial dispatch queues also provide built-in synchronization for queuedtasks, eliminating many of the problems normally associated with synchronization and memory contentionnormally encountered when 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

● 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 version 10.7, GCD supports asynchronous I/O through dispatch data and dispatch I/O.

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

High-Level Features 552011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 4

Core Services Layer

Page 56: OSX Technology Overview

Bonjour

Bonjour 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, RAIDservers, and wireless routers. When plugged in, these devices automatically publish the services they offerto clients on the network.

For information on how to incorporate Bonjour services into a Cocoa application, see Bonjour Overview.Bonjour for non-Cocoa applications is described in DNS Service Discovery Programming Guide.

Security Services

Mac 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

● Secure transport

● Keychain Services

Security Transforms, a technology which was introduced in Mac OS X v10.7, provide a universal context forall cryptographic work. A cryptographic unit in Security Transforms, known as a SecTransform, can be usedin multiple ways. There are SecTransforms for encryption, decryption, signing, verifying, digesting, andencoding. You can also create custom SecTransforms. SecTransforms are built upon GCD and define a data-flowmodel for 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 deprecated andits 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 74). For more information about the security architecture andsecurity-related technologies of Mac OS X, see Security Overview.

56 High-Level Features2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 4

Core Services Layer

Page 57: OSX Technology Overview

Speech Technologies

Mac 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 applications.

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 orattention disabilities. As with speech recognition, TTS provides an API and several user interface features tohelp you incorporate speech synthesis into your applications. You can also use speech synthesis to replacedigital audio files of 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.

Identity Services

Introduced in Mac OS X v10.5, Identity Services encompasses features located in the Collaboration and CoreServices frameworks. Identity Services provides a way to manage groups of users on a local system. In additionto standard login accounts, administrative users can now create sharing accounts, which use access controllists to restrict access to designated system or application resources. Sharing accounts do not have anassociated home directory on the system and have much more limited privileges than traditional loginaccounts.

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

Time Machine Support

Introduced in Mac OS X v10.5, the Time Machine feature protects user data from accidental loss byautomatically backing up data to a different hard drive. Included with this feature is a set of programmer-levelfunctions that you can use to exclude unimportant files from the backup set. For example, you might usethese functions to exclude your application’s cache files or any files that can be recreated easily. Excludingthese types of files improves backup performance and reduces the amount of space required to back up theuser’s system.

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

Keychain Services

Keychain 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 container

High-Level Features 572011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 4

Core Services Layer

Page 58: OSX Technology Overview

that holds passwords for multiple applications and secure services. Access to the keychain is provided througha single master password. Once the keychain is unlocked, Keychain Services–aware applications can accessauthorized information without bothering the user.

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

XML Parsing

Mac OS X includes several XML parsing technologies. Most applications 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 parsingXML content.

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

For information on parsing XML from a Cocoa application, see Event-Driven XML Programming Guide andTree-Based XML Programming Guide.

SQLite Database

The SQLite library lets you embed a SQL database engine into your applications. Programs that link with theSQLite library can access SQL databases without running a separate RDBMS process. You can create localdatabase files and manage the tables and records in those files. The library is designed for general purposeuse but is still 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 SQLitedatabases using 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 Notifications

A distributed notification is a message posted by any process to a per-computer notification center, whichin turn broadcasts the message to any processes interested in receiving it. Included with the notification isthe ID 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.

58 High-Level Features2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 4

Core Services Layer

Page 59: OSX Technology Overview

Distributed notifications are true notifications because there is no opportunity for the receiver to reply tothem. There is also no way to restrict the set of processes that receive a distributed notification. Any processthat registers for a given notification may receive it. Because distributed notifications use a string for theunique registration 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 Service Frameworks

Mac OS X includes several core services that make developing applications easier. These technologies rangefrom utilities 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 Framework

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

● Launch Services (LaunchServices.framework). Gives you a programmatic way to open applications,documents, URLs, or files with a given MIME type in a way similar to the Finder or the Dock. The LaunchServices framework also provides interfaces for programmatically registering the document types yourapplication 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 application to search for files based on metadata values and thensort the results based on certain criteria. (The Foundation framework offers an Objective-C interface tothe query API.)

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 application to support fastsearching of content managed by your application. This framework is part of the Core Services umbrellaframework.

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.

Core Service Frameworks 592011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 4

Core Services Layer

Page 60: OSX Technology Overview

● Dictionary Services (DictionaryServices.framework). Lets you create custom dictionaries thatusers can access through the Dictionary application. Through these services, your application can alsoaccess dictionaries programmatically and can support user access to dictionary look-up through acontextual menu.

For more information, see Dictionary Services Programming Guide.

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

Address Book

Address Book is technology that encompasses a centralized database for contact and group information, anapplication for viewing that information, and a programmatic interface for accessing that information in yourown programs. The database contains information such as user names, street addresses, email addresses,phone numbers, and distribution lists. Applications that support this framework (AddressBook.framework)can use this data as-is or extend it to include application-specific information. They can share user recordswith other applications, such as the Address Book application and the Apple Mail program.

Mac OS X version 10.7 brings a number of enhancements to the Address Book framework. Your applicationcan now use the Address Book to access Exchange and CardDAV contacts. It can also allow users to displayand edit contacts in a standardized user interface. The framework also now supports more instant-messagingservices and yearless dates.

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.

Automator

Introduced in Mac OS X v10.5, the Automator framework (Automator.framework) enables your applicationto run workflows, which string together the actions defined by various applications to perform complextasks automatically. Unlike AppleScript, which uses a scripting language to implement the same behavior,workflows are constructed visually, requiring no coding or scripting skills to create.

For information about incorporating workflows into your own applications, seeAutomator FrameworkReference.

Core Data

The Core Data framework (CoreData.framework) manages the data model of an application based on theModel-View-Controller design pattern. Instead of defining data structures programmatically, you use thegraphical tools in Xcode to build a schema representing your data model. At runtime, instances of yourdata-model entities are created, managed, and made available through the Core Data framework with littleor no coding on your part.

By managing your application’s data model for you, Core Data significantly reduces the amount of code youhave to write for your application. Core Data also provides the following features:

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

60 Core Service Frameworks2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 4

Core Services Layer

Page 61: OSX Technology Overview

● Management of undo/redo beyond basic text editing

● Support for validation of property values

● 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

In Mac OS X version 10.7 and later, Core Data includes two major enhancements: an incremental store APIand a work concurrency model API. With the incremental store API you can create Core Data stores thatconnect to any possible data source. These custom stores let your application load only the data that isnecessary for the current tasks. The work concurrency model API enables your application to share unsavedchanges between threads across the object graph efficiently.

If you are starting to develop a new application, or are planning a significant update to an existing application,you should consider using Core Data. For more information about Core Data, including how to use it in yourapplications, see Core Data Programming Guide.

Foundation and Core Foundation

The 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 application development (see “CocoaUmbrella Framework” (page 34)). Core Foundation, on the other hand, declares C-based programmaticinterfaces; it is intended to be used with other C-based frameworks such as Core Graphics.

Core Service Frameworks 612011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 4

Core Services Layer

Page 62: OSX Technology Overview

Note: Although you can use Core Foundation objects and call Core Foundation functions in Objective-Cprojects, 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 ofthe Core Foundation interfaces is more object-oriented than C. As a result, the opaque types (often referredto as objects) 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

Beginning in Mac OS X v10.7, the Foundation framework also offers the NSRegularExpression class, whoseobjects represent and apply regular expressions.

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

Quick Look

Introduced in Mac OS X v10.5, Quick Look is a technology that enables applications such as Spotlight andthe Finder display thumbnail images and full-size previews of documents. If your application defines customdocument formats that are different from the system-supported content types, you should provide a QuickLook generator for those formats. Generators are plug-ins that convert documents of the appropriate typefrom their native format to a format that Quick Look can display as thumbnails and previews to users.

In Mac OS X version 10.7, Quick Look allows users of your application to preview the contents of a documentembedded as a text attachment without requiring them to leave the application.

62 Core Service Frameworks2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 4

Core Services Layer

Page 63: OSX Technology Overview

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

Sync Services

The Sync Services framework (SyncServices.framework) gives you access to the data synchronizationengine built-in to Mac OS X. With this framework, your application can synchronize its data with systemdatabases, such as those provided by Address Book and iCal. You can also publish your application’s customdata types and make them available for syncing. You might do this to share your application’s data withother applications on the same computer or with applications on multiple computers (through the user’sMobileMe account).

Predefined schemas are provided for contacts, calendars, bookmarks, and mail notes (see Apple ApplicationsSchema Reference). You can also distribute custom schemas for your own data types and register them withSync Services.

For more information about using Sync Services in your application, see Sync Services Programming Guideand Sync Services Framework Reference.

WebKit

The WebKit framework (WebKit.framework) enables your application to display HTML content. It has twosubframeworks: Web Core and JavaScript Core. Web Core is for parsing and displaying HTML content;JavaScript Core 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 Layer

The 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 basedapplication. You can use this framework to fetch user calendars, events, and tasks from the iCal datastorage, receive notifications 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 displayingsharing account information and other identity-related user interfaces. With this API, applications candisplay information about users and groups and display a panel for selecting users and groups duringthe editing of access control lists. For related information, see “Identity Services” (page 57).

Core Service Frameworks 632011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 4

Core Services Layer

Page 64: OSX Technology Overview

● 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. This frameworkwas introduced in Mac OS X v10.5.

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

64 Core Service Frameworks2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 4

Core Services Layer

Page 65: 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.

Kernel and Device Drivers

Core OS

Directory ServicesAccelerate Disk Arbitration

OpenCL System Configuration

Core Services

Media

Cocoa (Application)

High-Level Features

The Core OS layer implements features related to application security.

Application Sandboxing and Privilege Separation

As applications become more dependent on networking, they become more exposed to data from untrustedsources. This data can become an attack vector for viruses, malware, and other forms of exploits. Even thebest code can have flaws that lead to potential security holes; through these breaches, malicious code canuse your process as a base from which to access other parts of the system or user data. By placing yourapplication in an app sandbox you can minimize the damage caused by any successful exploit. The appsandbox prevents access to system resources not used by the application and to files unrelated to theapplication. Application sandboxing is a security feature introduced in Mac OS X v10.7.

An app sandbox consists of two components: entitlements that declare the resources an application usesand a directory that contains the application’s files. When the sandboxing entitlements are present (throughcode signing), the system automatically creates the container directory. Sandboxing can be applied to typesof binaries other than applications, such as tools and daemons.

In addition, you can use privilege separation as a related technique for improving security. Privilege separation(also introduced in Mac OS X v10.7) is a technique for breaking up a common application, tool, or daemoninto pieces that individually require fewer rights. XPC Services (“XPC Interprocess Communication andServices” (page 69)) is the recommended interprocess-communication API to use for privilege separation.

High-Level Features 652011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 5

Core OS Layer

Page 66: OSX Technology Overview

For an overview of application sandboxing, read “The App Sandbox” in Mac OS X Application ProgrammingGuide. To learn about application sandboxing and privilege separation in depth, read Code Signing Guide.

Code Signing

In Mac OS X v10.5 and later, it is possible to associate a digital signature with your application using thecodesign command-line tool. If you have a certificate that is authorized for signing, you can use thatcertificate to sign your application’s code file. Signing your application makes it possible for Mac OS X toverify the source of the application and ensure the application has not changed since it was shipped. If theapplication has been tampered with, Mac OS X detects the change and can alert the user to the problem.Signed applications also make it harder to circumvent parental controls and other protection features of thesystem.

For information on signing your application, see Code Signing Guide.

Core OS Frameworks

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

Accelerate

You can use the Accelerate framework (Accelerate.framework) to accelerate complex operations usingthe available vector unit and thereby improve performance. Hardware-based vector units boost theperformance of any application that exploits data parallelism, such as those that perform 3D graphic imaging,image processing, video processing, audio compression, and software-based cell telephony. (Quartz andQuickTime Kit incorporate vector capabilities, thus any application using these APIs can tap into this hardwareacceleration without making any changes.)

The Accelerate framework supports both the PowerPC AltiVec and Intel x86 SSE extensions internally butprovides a single interface for you to use in your application. The advantage of using this framework is thatyou can simply write your code once without having to code different execution paths for each hardwareplatform. The functions of this framework are highly tuned for the specific platforms supported by Mac OSX and in many cases 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-buffermanipulations.

For information on how to use the components of the Accelerate framework, see vImage ProgrammingGuide,vImageReferenceCollection, and vecLibReference. For general performance-related information, see PerformanceOverview.

66 Core OS Frameworks2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 5

Core OS Layer

Page 67: OSX Technology Overview

Disk Arbitration

The Disk Arbitration framework (DiskArbitration.framework) notifies your application when local andremote volumes are mounted and unmounted. It also furnishes other updates on the status of remote andlocal mounts and returns information about mounted volumes. For example, if you provide the frameworkwith the BSD disk identifier of a volume, you can get the volume’s mount-point path.

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

OpenCL

Introduced 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 generalpurpose computer language, not specifically a graphics language, that abstracts out the lower-level detailsneeded to perform parallel data computation tasks on GPUs and CPUs. Using OpenCL, you create computekernels that are then offloaded to a graphics card or CPU for processing. Multiple instances of a computekernel can be run in parallel on one or more GPU or CPU cores, and you can link to your compute kernelsfrom Cocoa, C, or C++ applications.

For tasks that involve data-parallel processing on large data sets, OpenCL can yield significant performancegains. There are many applications that are ideal for acceleration using OpenCL, such as signal processing,image manipulation, or finite element modeling. The OpenCL language has a rich vocabulary of vector andscalar operators 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 informationstored in local or network databases. Directory services typically provide access to collected informationabout users, groups, computers, printers, and other information that exists in a networked environment(although they can also store information about the local system). You use Open Directory in your programsto retrieve information from these local or network databases. For example, if you’re writing an email program,you can use Open Directory to connect to a corporate LDAP server and retrieve the list of individual andgroup email addresses for the company.

Open Directory uses a plug-in architecture to support a variety of retrieval protocols. Mac OS X providesplug-ins to support LDAPv2, LDAPv3, NetInfo, AppleTalk, SLP, SMB, DNS, Microsoft Active Directory, andBonjour protocols, 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.

Core OS Frameworks 672011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 5

Core OS Layer

Page 68: OSX Technology Overview

System Configuration Framework

System Configuration is a framework (SystemConfiguration.framework) through which applicationscan configure networks and determine if networks can be reached prior to connecting with them. WithSystem Configuration, your application can determine and set configuration settings and respond dynamicallyto changes in that information. It can also determine if a remote host is reachable and, if it is, request anetwork connection so it can provide content to its users. To assist in this, System Configuration does thefollowing:

● It provides access to current network configuration information.

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

● It notifies applications 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.

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

68 Core OS Frameworks2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 5

Core OS Layer

Page 69: 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 andlook for recently introduced technologies.

MachBSD NetworkingFile System

Kernel and Device Drivers

Core OS

Core Services

Media

Cocoa (Application)

High-Level Features

The following are important features added to Mac OS X in recent major versions.

XPC Interprocess Communication and Services

XPC is a low-level library (libSystem) interface for interprocess communication. It is typically used inconjunction with XPC Services (XPCServices.framework) to implement privilege separation in a sandboxedapplication. Both parts of XPC—the interprocess-communication API and XPC Services— were introducedin Mac OS X v10.7.

You implement XPC Services as one or more standalone bundles inside the bundle of an application. Throughits information property list (Info.plist), an XPC Service bundle specifies its own sandboxing entitlementkeys. The bundle binary must call a registration function and implement an event handler for IPC messagesreceived from its application. When the application is launched, the system automatically registers each XPCservice it finds into the namespace visible to the application. An application establishes a connection withone of its XPC services and sends it messages containing events that the service then handles.

High-Level Features 692011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 6

Kernel and Device Drivers Layer

Page 70: OSX Technology Overview

XPC (as an interprocess-communication API) is declared in /usr/include/xpc. It enables you to create andmanipulate property-list objects to be sent to bundled services. Supported objects include dictionaries, arrays,strings, and integers, and can include out-of-line data types such as shared-memory regions and file descriptors.(Note that these are not property-list objects as defined by Core Foundation or Foundation.) XPC also includesfunctions for connecting to XPC services and sending messages, with or without receiving back replies. XPCis integrated with Grand Central Dispatch (GCD); when you create a connection, you associate it with adispatch queue on which message traffic executes. With XPC you can also create endpoints, objects that youcan send to other processes to allow them to create connections.

For more on XPC Services, see “Creating XPC Services” in Daemons and Services Programming Guide. To learnmore about application sandboxing, read Code Signing Guide.

Caching API

Introduced in Mac OS X v10.6, the libcache API is a low-level purgeable caching API. Aggressive cachingis an 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, thismeans paging cached data to and from relatively slow storage devices, sometimes even resulting insystem-wide performance degradation. Your application should avoid potential paging overhead by activelymanaging its data 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 libcacheReference. For more informationabout the NSCache class, see NSCache Class Reference.

The Kernel

Beneath 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.

Mach

Mach 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 CPUusage and 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

70 The Kernel2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 6

Kernel and Device Drivers Layer

Page 71: OSX Technology Overview

system crashes. Mach ensures that an application cannot write in another application’s memory or inthe operating system’s memory. By walling off applications from each other and from system processes,Mach makes it virtually impossible for a single poorly behaved application to damage the rest of thesystem. Best of all, if an application crashes as the result of its own misbehavior, the crash affects onlythat application and not 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 ensuringthat every task gets the resources it needs. It uses certain criteria to decide how important a task is andtherefore how much time to allocate to it before giving another task its turn. Your process is notdependent on another 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 virtualaddress space is 4 GB. For 64-bit applications, the theoretical maximum is approximately 18 exabytes,or 18 billion billion bytes. Mach maintains address maps that control the translation of a task’s virtualaddresses into physical memory. Typically only a portion of the data or code contained in a task’s virtualaddress space resides in physical memory at any given time. As pages are needed, they are loaded intophysical memory from storage. Mach augments these semantics with the abstraction of memory objects.Named memory objects enable one task (at a sufficiently low level) to map a range of memory, unmapit, and send it to another task. This capability is essential for implementing separate executionenvironments on the same system.

● 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 Kernel

Mac 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.

The Kernel 712011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 6

Kernel and Device Drivers Layer

Page 72: OSX Technology Overview

Device-Driver Support

Darwin 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 toa published 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.

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

Network Kernel Extensions

Darwin 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 itpossible to 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.

BSD

Integrated 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)

72 BSD2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 6

Kernel and Device Drivers Layer

Page 73: OSX Technology Overview

● Networking support (BSD sockets)

Note: For more information about the FreeBSD operating system, go to http://www.freebsd.org/. For moreinformation about the boot process of Mac OS X, including how it launches the daemons used to implementkey 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.

IPC and Notification Mechanisms

Mac 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 asat the creation, modification, or removal of files and directories. The FSEvents API gives you a way tomonitor many directories at once and detect general changes to a file hierarchy. However, it is notintended for detecting fine-grained changes to individual files. For example, you might use this technologyin backup software to detect what files changed. This technology was introduced in Mac OS X v10.5.

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 queuesand events are part of the FreeBSD layer of the operating system and are described in the kqueue andkevent man pages.

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

You can add support for BSD notifications to any type of program, including Cocoa applications. Formore information, see Mac OS X Notification Overview or the notify man page. See “DistributedNotifications” (page 58) for a discussion of Cocoa and Core Foundation interfaces for interprocessnotification.

● 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 Foundationand Foundation (which work with CFNetwork) provide a stream-based way to read and write networkdata and can be used with run loops to operate efficiently in a network environment.

BSD 732011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 6

Kernel and Device Drivers Layer

Page 74: OSX Technology Overview

● 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 cancreate named 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.

● Shared memory. A region of memory that has been allocated by a process specifically for the purposeof being readable and possibly writable among several processes. You can create regions of sharedmemory using several BSD approaches, including the shm_open and shm_unlink routines, and themmap routine. Access to shared memory is controlled through POSIX semaphores, which implement akind of locking mechanism.

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 torequest services and information from other applications. To supply services, you define objects in yourapplication that can be accessed using Apple events and then provide Apple event handlers to respondto requests for 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, messagingwith Mach port objects is the least desirable way to communicate between processes. Mach port messagingrelies on knowledge of the kernel interfaces, which may change in a future version of Mac OS X. The onlytime you might consider using Mach ports directly is if you are writing software that runs in the kernel.

Network Support

Mac 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 fromApple.

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

Standard Network Protocols

Mac 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.

74 BSD2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 6

Kernel and Device Drivers Layer

Page 75: OSX Technology Overview

Table 6-1 Network protocols

DescriptionProtocol

802.1x is a protocol for implementing port-based network access over wired or wirelessLANs. 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 automate theassignment of IP addresses in a particular network.

DHCP and BOOTP

Domain Name Services is the standard Internet service for mapping host names to IPaddresses.

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-based dial-upconnection for broadband users.

PPPoE

The Secure MIME protocol supports encryption of email and the attachment of digitalsignatures 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 another computer.Session information is encrypted to prevent unauthorized access of data.

SSH

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 and UDP/IP

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

BSD 752011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 6

Kernel and Device Drivers Layer

Page 76: OSX Technology Overview

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

Network Technologies

Mac 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 and increasesthe 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 links thatcan 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

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 server isintegrated as the system’s HTTP service.

Personal web sharing

Network Diagnostics

Network 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 computeris configured. The network diagnostics feature provides a diagnostic application to help the user locateproblems and correct them.

76 BSD2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 6

Kernel and Device Drivers Layer

Page 77: OSX Technology Overview

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 Support

The 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 eachconnected removable 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 asAppleShare and 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

Because of its multiple application environments and the various kinds of devices it supports, Mac OS Xhandles file 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 single file.

Mac OS ExtendedFormat

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 OS StandardFormat

Universal Disk Format, used for hard drives and optical disks, including most typesof CDs and DVDs. Mac OS X v10.5 and later supports reading UDF revisions 1.02through 2.60 on both block devices and most optical media, and it supports writingto block devices and to DVD-RW and DVD+RW media using UDF 2.00 through 2.50(except for mirrored metadata partitions in 2.50). You can find the UDF specificationat http://www.osta.org.

UDF

The standard format for CD-ROM volumes.ISO 9660

BSD 772011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 6

Kernel and Device Drivers Layer

Page 78: OSX Technology Overview

DescriptionVolume format

The NT File System, used by Windows computers. Mac OS X can read NTFS-formattedvolumes 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 important formany 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 linksand hard links but not aliases. Although an alias and a symbolic link are both lightweight references to a fileor directory elsewhere in the file system, they are semantically different in significant ways. For moreinformation, see “Aliases and Symbolic Links” in File System 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 (available onlyover 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

Security

The 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 cryptographicalgorithms. It is intended to replace similar OpenSSL interfaces.

78 BSD2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 6

Kernel and Device Drivers Layer

Page 79: OSX Technology Overview

Note: Beginning in Mac OS X v10.7, CDSA (Common Data Security Architecture) and OpenSSL have beendeprecated and their further use is discouraged. The Security Transforms technology is a possible replacementfor CDSA and CommonCrypto is the possible replacement for OpenSSL. Security Transforms, which are partof the Security framework, are described in “Security Services” (page 56).

In Mac OS X v10.5 several improvements were made to the underlying operating system security, includingthe addition of the following 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.

● 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 Support

Darwin 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, and others.

In Mac OS X v10.5, Darwin added support for several new scripting features. In addition to supporting Rubyon Rails, Mac OS X also provides scripting bridges to the Objective-C classes of Cocoa. These bridges let youuse Cocoa classes from within your Python and Ruby scripts. For information about using these bridges, seeRuby and Python Programming Topics for Mac OS X.

Threading Support

Mac 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 performanceimprovements in your application, especially on computers with multiple CPU cores. Multithreadedprogramming is not without its dangers though. It requires careful coordination to ensure your application’sstate does not get corrupted.

BSD 792011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 6

Kernel and Device Drivers Layer

Page 80: OSX Technology Overview

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, Carbon, or Java, all of whichare implemented using pthreads. Each threading package offers a different combination of flexibility versusease-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 informationabout threading support and guidelines on how to use threads safely, see Threading Programming Guide.

X11

The 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 windowsfrom native applications written in Carbon and Cocoa.

Software Development Support

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

Binary File Architecture

The underlying architecture of Mac OS X executables was built from the beginning with flexibility in mind.This flexibility has become important as Macintosh computers have transitioned from using PowerPC to IntelCPUs and from supporting only 32-bit applications to 64-bit applications in Mac OS X v10.5. The followingsections provide an overview of the types of architectures you can support in your Mac OS X executablesalong with other information about the 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)

80 BSD2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 6

Kernel and Device Drivers Layer

Page 81: OSX Technology Overview

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.

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 forin your code. For example, the PowerPC and Intel architectures use different endian structures for multibytedata. In addition, some built-in data types have different sizes in 32-bit and 64-bit architectures. Accountingfor these 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 Intelarchitectures, see Universal Binary Programming Guidelines, Second Edition. For information about 64-bitsupport in Mac OS X, including links to documentation for how to make the transition, see “64-BitSupport” (page 81).

64-Bit Support

Mac OS X was initially designed to support binary files on computers using a 32-bit architecture. In Mac OSX v10.4, however, support was introduced for compiling, linking, and debugging binaries on a 64-bitarchitecture. This initial support was limited to code written using C or C++ only. In addition, 64-bit binariescould link against 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 theavailability of extra processor resources in 64-bit mode.

Although most APIs support 64-bit development, some older APIs were not ported to 64-bit or offer restrictedsupport for 64-bit applications. Many of these APIs are legacy Carbon managers that have been either whollyor partially deprecated in favor of more recent equivalents. What follows is a partial list of APIs that will notsupport 64-bit. For a complete description of 64-bit support in Carbon, see 64-Bit Guide for CarbonDevelopers.

● Code Fragment Manager (use the Mach-O executable format instead)

● Desktop Manager (use Icon Services and Launch Services instead)

● Display Manager (use Quartz Services instead)

● QuickDraw (use Quartz or Cocoa instead)

● QuickTime Musical Instruments (use Core Audio instead)

● Sound Manager (use Core Audio instead)

BSD 812011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 6

Kernel and Device Drivers Layer

Page 82: OSX Technology Overview

In addition to the list of deprecated APIs, there are a few non-deprecated APIs that have not been ported to64-bit. Development of 32-bit applications with these APIs is still supported, but if you want to create a 64-bitapplication, 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 Developersfor the 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. For Carbon-specific transition information, see 64-Bit Guide for Carbon Developers.

Object File Formats

Mac OS X is capable of loading object files that use several different object-file formats, including the following:

● Mach-O

● Java bytecode

Of these formats, the Mach-O format is the format used for all native Mac OS X application development.The Java bytecode format is a format executed through the Hotspot Java virtual machine and used exclusivelyfor Java-based programs.

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. For information about Java supportin Mac OS X, see “Java Support” (page 84).

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 veryimportant to 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;see Mac OS X ABI Mach-O File Format Reference. With the DWARF format, however, debugging symbols arestored either 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.

82 BSD2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 6

Kernel and Device Drivers Layer

Page 83: OSX Technology Overview

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.

Upon loading a program’s code modules, the dynamic loader performs the minimal amount of symbolbinding needed to launch your program and get it running. This binding process involves resolving links toexternal libraries and loading them as their symbols are used. The dynamic loader takes a lazy approach tobinding individual symbols, doing so only as they are used by your code. Symbols in your code can bestrongly-linked or weakly-linked. Strongly-linked symbols cause the dynamic loader to terminate your programif the library containing the symbol cannot be found or the symbol is not present in the library. Weakly-linkedsymbols terminate 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.

Java Runtime Environment

The Java runtime environment consists of the HotSpot Java virtual machine, the “just-in-time” (JIT) bytecodecompiler, and code packages containing the standard Java classes. For more information about Java supportin Mac OS X, see “Java Support” (page 84).

Language Support

The 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. It also includes a Javaruntime that you can use to write Java applications. Support for other languages may also be provided bythird-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 mucheasier to extend the behavior of code at runtime without having access to the original source.

In Mac OS X v10.5, an update to the Objective-C language (called Objective-C 2.0) was introduced, addingsupport for the following features:

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

BSD 832011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 6

Kernel and Device Drivers Layer

Page 84: OSX Technology Overview

● Support for garbage collection; see Garbage Collection Programming Guide

● A new 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.

Java Support

The following sections outline the support provided by Mac OS X for creating Java-based programs.

Note: The developer documentation on the Apple website contains an entire section devoted to Java. Thereyou can find detailed information on the Java environment and accompanying technologies for operatingin Mac OS X. For an introduction to the Java environment and pointers to relevant documentation on Javaprogramming in Mac OS X, see Getting Started with Java.

The Java Environment

The libraries, JAR files, and executables for the Java application environment are located in the/System/Library/Frameworks/JavaVM.framework directory. The Java application environment hasthree major components:

● A development environment, comprising the Java compiler (javac) and debugger (jdb) as well as othertools, including javap, javadoc, and appletviewer. You can also build Java applications using Xcode.

● A runtime environment consisting of Sun’s high-performance HotSpot Java virtual machine, the“just-in-time” (JIT) bytecode compiler, and several basic packages, including java.lang, java.util,java.io, and java.net.

● An application framework containing the classes necessary for building a Java application. This frameworkcontains the Abstract Windowing Toolkit (java.awt) and Swing (javax.swing) packages, amongothers. These packages provide user interface components, basic drawing capabilities, a layout manager,and an event-handling mechanism.

Like Carbon and Cocoa applications, a Java application can be distributed as a double-clickable bundle. TheJar Bundler tool takes your Java packages and produces a Mac OS X bundle. This tool is installed along withXcode and the rest of the Apple developer tools on the Xcode Tools CD.

If you want to run your Java application from the command line, you can use the java command. To launcha Java application from another program, use the system exec call or the Java Runtime.exec method. Torun applets, embed the applet into an HTML page and open the page in Safari.

Java and Other Application Environments

Java applications can take advantage of Mac OS X technologies such as Cocoa and QuickTime through Sun’sJava Native Interface (JNI). For details on using the JNI on Mac OS X, see Technical Note 2147.

84 BSD2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 6

Kernel and Device Drivers Layer

Page 85: 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 not exactly the same as their iOScounterparts. This chapter describes the differences you may encounter as you create Mac OS X applicationsand explains how 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 Notes

In Mac OS X, applications typically have a screen that is larger, and resources that are greater, than in iOS.You also 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 Model

Cocoa 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 bothframeworks, and they are virtually identical to their iOS counterparts. Most of the differences that do existare relatively minor or are related to features that are not present in iOS. For example, iOS applications donot support AppleScript. For a detailed list of differences, see “Foundation Framework Differences” (page95).

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 doesin iOS), but it also supports XML data stores. For the supported data stores, you can copy your Core Dataresource files to your Mac OS X application project and use them as is. For information on how to use CoreData in your Xcode projects, see Core Data Programming Guide.

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 X

General Migration Notes 852011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 7

Migrating from Cocoa Touch

Page 86: OSX Technology Overview

system 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 youralgorithms scale to the new platform.

Managing Memory

Cocoa applications in Mac OS X can manage memory either by using garbage collection or by explicitlymanaging memory—that is, using the model for creating, copying, retaining, releasing, and autoreleasingobjects. In iOS, you can use only the explicit memory-managed model. If you maintain a code base that iscommon to the two platforms, you might choose to use explicit memory management in your applicationprojects to help ensure the code is error free.

If you don’t want to use explicit memory management for your Mac OS X application, you can adopt thegarbage collection model. Garbage collection is a runtime technology that automatically looks for and discardsobjects that an application no longer needs. Garbage collection is an opt-in feature. If you turn on garbagecollection, your memory-management calls (retain, release, and so on) are ignored. To learn aboutgarbage collection, read Garbage Collection Programming Guide.

Migrating Your User Interface

The 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 88) 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 alaptop or desktop system where applications have much greater screen real estate, a more dependablesupply of power, and a much larger pool of memory to draw upon. These physical differences play arole in how an 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 isonly one window per application in iOS; that window has a fixed size, plays a limited role in the userinterface, and cannot be manipulated by users. On the other hand, a Mac OS X application can (andoften does) have multiple windows. These windows can be for individual documents, or they can besecondary windows for 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 ofvirtually any number and size, you can present related information at the same time instead of (as iniOS) breaking it into chunks and deciding what order to present those chunks.

● Mode of interaction. The way users interact with the device or computer influences characteristics ofthe user interface. A mobile device has a smaller screen than that of a desktop system. And because itis meant to be mobile, it shouldn’t be encumbered by requiring input devices other than the humanfinger. The model for user input is thus direct manipulation by touching objects on the screen with oneor more fingers. However, the finger is a less-than-precise pointer, and so views must be large enoughto be targets of 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 Xthan in iOS. In addition, a mouse is not simply a pointing instrument; it has buttons and is therefore

86 General Migration Notes2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 7

Migrating from Cocoa Touch

Page 87: OSX Technology Overview

capable of multiple forms of input related to the same target. Not only can you click a view with a mousepointer but, by hovering the mouse over a view, you might be able to get other responses—for example,tool tips.

● 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 handledocuments and other files that users select, and this preparation can entail issues related to documentformat, file encoding, and so on. However, not all Mac OS X applications do this; some applications (forexample, iPhoto and iTunes) keep their databases in a well-known location and provide ways to findfiles automatically without a user’s intervention.

For general information about the user interface design principles of Mac OS X, see MacOS XHuman 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 OS X Application Programming Guide.

Migrating Your Controller Layer

Controller objects are a critical area of difference between application development for iOS and for Mac OSX. 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 multiplewindows that 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 notavailable in iOS, can be a valuable asset in the development process.

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.

General Migration Notes 872011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 7

Migrating from Cocoa Touch

Page 88: OSX Technology Overview

Application Types

When 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 MacOS X application project, there are only two application types to choose from (disregarding for the momentthe application templates Cocoa-AppleScript and Quartz Composer):

● A single-window application

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

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

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

Migration Guidelines

Here 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 ofiOS on a Mac OS X application—for example, don’t try to implement a stack of view controllers. Keepwith the strengths 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 tooperate in.

● 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.

Differences Between the UIKit and AppKit Frameworks

In 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.

88 Differences Between the UIKit and AppKit Frameworks2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 7

Migrating from Cocoa Touch

Page 89: OSX Technology Overview

User Events and Event Handling

Handling events in Mac OS X differs significantly from handling events in iOS applications, mainly becausethe types of user events for each platform differ. If your application does its own event handling, you willhave to rewrite 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 tointeract with 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 classof the 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.

Windows

At 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:

● 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 sizeand have distinct styles. Whereas an iOS window has no visual adornments, a Mac OS X window usuallyhas a title, may have a toolbar, and can have controls for moving, closing, resizing, and minimizing thewindow.

● 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.

Differences Between the UIKit and AppKit Frameworks 892011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 7

Migrating from Cocoa Touch

Page 90: OSX Technology Overview

● 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 inwindows; you just have to do animation explicitly, at the view level.) See Table 7-2 (page 94) for asummary of Core Animation differences.

Menus

Nearly 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 menushas standard menu items. When you create a Mac OS X application project in Xcode, the nib-file templateprovides you with a “starter set” of menus for your application menu bar; remove and add menus and menuitems from the 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 canassign key 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.

Documents

A 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 forthe platform. This architecture is closely based on the Model-View-Controller design pattern. Each documenthas its own main window and can have secondary windows for auxiliary functions. As noted in “ApplicationTypes” (page 88), 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 OS X Application Programming Guide.

90 Differences Between the UIKit and AppKit Frameworks2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 7

Migrating from Cocoa Touch

Page 91: OSX Technology Overview

Views and Controls

Some 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,you must find a suitable alternative. For example, AppKit uses the NSBrowser class to manage the displayof hierarchical information rather than the UIKit paradigm of navigation controllers. Moreover, some viewsthat seem similar have different inheritance characteristics; for example, UITableView objects inherit fromthe UIScrollView class whereas NSTableView objects inherit from NSControl, the base class for controlsin AppKit.

Even though the base classes for views on both platforms—UIView and NSView—are somewhat similar,there are fundamental differences between them.

● Core Animation layers. iOS views are layer-backed by default. iOS applications typically manipulateviews by changing properties of the view. In Mac OS X, an application must opt in to make its views layerbacked. Consequently, it is more common for AppKit views to perform the same manipulations in theirdrawRect: method. Table 7-2 (page 94) gives more information about differences related to CoreAnimation 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 92) foradditional information.

● Use of cells for controls. Because AppKit views can incur significant overhead, some AppKit controlsuse cells (that is, NSCell objects) as a lightweight alternative to views. A cell holds the information thatits control needs in order to send an action message; a cell also draws itself when commanded by itscell. Cells make possible controls such a matrix object and a table view that have two-dimensional arraysof active subregions.

For functional descriptions of the views and controls available in Mac OS X, along with information on howto use them, seeMacOSXHuman InterfaceGuidelines. To learn about the common characteristics and behaviorof AppKit views, see View Programming Guide. For information about AppKit controls, read Control and CellProgramming Topics for Cocoa.

File System

Many Mac OS X applications let users locate files and directories in the file system, save files to specificfile-system locations, open files, and do other file-system operations. An iOS application, on the other hand,must perform all file-reading and file-writing operations within the confines of its sandbox. Beginning in MacOS X version 10.7, desktop and laptop applications can also be “sandboxed” (see “Application Sandboxingand Privilege Separation” (page 65)), and this can restrict the file-system operations they can perform.Nonetheless, even these applications might have to be prepared to open and save files in the file system asthe user directs (assuming that the user has the necessary file permissions).

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 beingselected, and obtain users’ choices. You can also attach custom accessory views to these browsers.

Differences Between the UIKit and AppKit Frameworks 912011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 7

Migrating from Cocoa Touch

Page 92: OSX Technology Overview

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 standarddirectory locations other than Documents. For example, your application might want to write or read datain the Library/Application Support folder in the user’s home directory.

Note: Mac OS X applications should not store files in ~/Documents unless the user selects that locationusing the Save panel. They should always store files they create in an appropriate location in the user’sLibrary 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 Printing

There 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 haveclasses for drawing Bezier paths and categories for drawing strings. Both have functions for stroking andfilling rectangles. Both have programmatic facilities for obtaining and transforming graphics contexts ofvarious types. In some cases, you can migrate code that uses UIKit methods and functions to correspondingAppKit methods 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 image fromsource data appropriate to an outputdestination.

NSImageUIImageImages

Applications can use NSColorSpaceto more precisely define the colorsrepresented by NSColor objects.

NSColor,NSColorSpace,color-related viewclasses

UIColorColors

NSBezierPathUIBezierPathBezier paths

NSGraphicsContextFunctions declared inUIGraphics.h.

Graphicscontexts

92 Differences Between the UIKit and AppKit Frameworks2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 7

Migrating from Cocoa Touch

Page 93: OSX Technology Overview

CommentsMac OS X (AppKit)iOS (UIKit)

The PDF support in Mac OS X is muchricher.

PDF Kit frameworkFunctions declared inUIGraphics.h.

PDF

The classes and techniques forprinting in each platform arecompletely different.

Multiple classesMultiple classes (iOS 4.2and later)

Printing

As when using UIKit to draw or perform other graphical operations, you can call Core Graphics functionswhen the 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 geometric primitives,AppKit uses its own defined types for the same purpose—for example, NSRect and NSPoint.

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.

Text

AppKit 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,and it provides a comparable set of behaviors; thus, Cocoa applications in Mac OS X rarely need to use CoreText directly.

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.If your iOS application uses Core Text to draw and manage fonts and text layout, you can migrate much ofthat code to your Mac OS X application.

For an introduction to the text system of AppKit, see Cocoa Text Architecture Guide.

Table Views

Table 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.

Differences Between the UIKit and AppKit Frameworks 932011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 7

Migrating from Cocoa Touch

Page 94: 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 anotherAppKit view 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 ofthe table view intersect. A table view’s cells can be based on NSCell objects or, with Mac OS X version 10.7,NSView objects. View-based table views are the preferred alternative. Populating AppKit table views is similarto populating 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 viewfor subsequent 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 informationabout creating and using table views, see Table View Programming Guide.

Other Interface Differences

When migrating your application, you should keep in mind other technology differences between UIKit andAppKit; Table 7-2 summarizes these differences.

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 in iOS),but an application has to explicitly request this backing for its views. Once this requestis made, animation is supported for changes in the properties of the views. In AppKityou don’t get the same easy-to-use view-based animation support that you do 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, see AnimationOverview.

Core Animationlayers

94 Differences Between the UIKit and AppKit Frameworks2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 7

Migrating from Cocoa Touch

Page 95: OSX Technology Overview

DiscussionDifference

Target-action in AppKit defines only one form for method signatures, unlike UIKit, whichhas three forms. Controls in AppKit send their action messages in response to a discreteuser action, such as a mouse click; the notion of multiple actions associated with multipleinteraction phases does not exist on the platform. However, a control composed ofmultiple 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 for Cocoa.

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 OS Xincludes window controllers and the view hierarchies of key windows and main windows.AppKit also uses the responder chain for cooperative error handling.

To learn more about the responder chain, see Cocoa Event-Handling Guide.

Responder chain

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 open thiswindow by choosing Preferences from the application menu. In addition, Mac OS Xintegrates user preferences into Cocoa bindings and enables command-line access tothe 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.

User preferences

UIKit makes extensive use of properties throughout its class declarations, but AppKitmostly declares accessor methods instead of properties.

Accessormethods versusproperties

Foundation Framework Differences

A 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.

Foundation Framework Differences 952011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 7

Migrating from Cocoa Touch

Page 96: OSX Technology Overview

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 a computerusing file metadata. (Metadata is data about a file, rather than the actual filecontents.) If you want your application to create Spotlight queries and interactwith 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, establish aconnection between an item of data encapsulated by a model object and thepresentation of that data in a view. It eliminates the need for glue code in thecontroller layer of an application.

See Cocoa Bindings Programming Topics for more information.

Cocoa bindings

Using certain classes of Foundation along with supporting technology, you canmake an application scriptable. A scriptable application is one that responds tocommands in AppleScript scripts.

See Cocoa Scripting Guide to learn more about this technology.

Cocoa scripting(AppleScript)

Distributed objects is an interprocess messaging technology. With distributedobjects, an object in an application can send a message to an object in a differentCocoa application in the same network or in a different network. The port nameserver is an object that provides a port-registration service to distributed objects.

For information about this technology, see Distributed Objects ProgrammingTopics.

Distributed objects andport 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 Frameworks

The 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 audiovisualmedia, however, is different on the two platforms—specifically, Mac OS X does not have the Media Playerframework.

There are substantial differences between the audio frameworks of iOS and the audio frameworks of MacOS X. The following are the audio technologies of Mac OS X (as of Mac OS X version 10.7) that are not presentin iOS:

96 Differences in the Audio and Video Frameworks2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 7

Migrating from Cocoa Touch

Page 97: OSX Technology Overview

● Programmatic interfaces in the Audio Unit framework for creating dynamically-loadable plug-ins foraudio processing (audio units) and conversion (audio codecs), along with bundled user interfaces foraudio 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 usemultichannel audio and surround sound

● Programmatic interfaces in the Core MIDI framework for music sequencing

● Audio development tools (AU Lab, auval, afconvert)

Note: AV Foundation includes classes for playing and recording audio. These classes are adequate to theaudio 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 interfacesfor input clicks, and the audio-session interfaces in the Audio Toolbox and AV Foundation frameworks,including the 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 andWindows systems.

To learn more about AV Foundation, see AV Foundation Programming Guide.

Differences in Other Frameworks Common to Both Platforms

Table 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 this frameworkis 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 Mac OS X.

AddressBook.framework

Differences in Other Frameworks Common to Both Platforms 972011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 7

Migrating from Cocoa Touch

Page 98: OSX Technology Overview

DifferencesFramework

This framework contains the Core Foundation Network interfaces. In MacOS X, the CFNetwork framework is a subframework of an umbrellaframework, Core Services. Most of the interfaces, however, are the samefor iOS and Mac OS X.

For more information, see CFNetwork Framework Reference.

CFNetwork.framework

This framework contains the Quartz interfaces. You can use Quartz to createpaths, gradients, shadings, patterns, colors, images, and bitmaps in exactlythe same way you do in iOS. The Mac OS X version of Quartz has featuresnot present in iOS, including PostScript support, image sources anddestinations, Quartz Display Services support, and Quartz Event Servicessupport. In Mac OS X, the Core Graphics framework is a subframework ofthe Application Services umbrella framework and is not a top-levelframework, 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 used in iOS.This fuller-featured version of OpenGL is intended for desktop systems.The programmatic interface of OpenGL is much larger than the one forOpenGLES. OpenGL has many extensions that are not available in theembedded version of the framework.

For information about the OpenGL support in Mac OS X, see OpenGLProgramming Guide for Mac OS X.

OpenGL.framework

This framework contains the Core Animation, Core Image, and Core Videointerfaces. Most of the Core Animation interfaces are the same for Mac OSX and iOS. However, the iOS version of the framework lacks the API supportfor layout constraints and Core Image filters found 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 display ofcertificate 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 interfaces youfind in iOS.

For more information, see System Configuration Programming Guidelines.

System-Configuration.framework

98 Differences in Other Frameworks Common to Both Platforms2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

CHAPTER 7

Migrating from Cocoa Touch

Page 99: OSX Technology Overview

This appendix contains information about the frameworks of Mac OS X. These frameworks provide theinterfaces you need to write software for the platform. Some of these frameworks contain simple sets ofinterfaces while others contain multiple subframeworks. Where applicable, the tables in this appendix listany key prefixes used by the classes, methods, functions, types, or constants of the framework. You shouldavoid using any of the specified prefixes in your own symbol names.

System Frameworks

Table 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 for vector-optimizedoperations. See “Accelerate Framework” (page106).

cblas,vDSP, vv

10.3Accelerate.framework

Contains functions for creating and accessing asystemwide database of contact information.

AB, ABV10.2AddressBook.framework

Contains Carbon interfaces for OpenGL.AGL, GL,glm, GLM,glu, GLU

10.0AGL.framework

Contains classes and methods for the Cocoauser-interface layer. In general, link toCocoa.framework instead of this framework.

NS10.0AppKit.framework

Deprecated. Use AppKit.framework instead.N/A10.0AppKit-Scripting.framework

Contains interfaces for creating AppleScriptplug-ins.

ASK10.0AppleScriptKit.framework

Contains Objective-C extensions for creatingAppleScript plug-ins.

NS10.6AppleScriptObj-C.framework

Contains utilities for handling URLs in AppleShareclients.

AFP10.0AppleShareClient-Core.framework

System Frameworks 992011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

APPENDIX A

Mac OS X Frameworks

Page 100: OSX Technology Overview

DescriptionPrefixesFirstavailable

Name

Umbrella framework for several application-levelservices. See “Application ServicesFramework” (page 106).

AE, AX,ATSU, CG,CT, LS, PM,QD, UT

10.0Application-Services.framework

Contains interfaces for getting audio stream data,routing audio signals through audio units,converting between audio formats, and playingback music.

AU, AUMIDI10.0AudioToolbox.framework

Contains interfaces for defining Core Audioplug-ins.

AU10.0AudioUnit.framework

Umbrella framework for creating Automatorplug-ins. See “Automator Framework” (page 107).

AM10.4Automator.framework

Provides interfaces for playing, recording,inspecting, and editing audiovisual media.

AV10.7AVFoundation.framework

Contains interfaces for managing iCal calendardata.

Cal10.5CalendarStore.framework

Umbrella framework for Carbon-level services.See “Carbon Framework” (page 107).

HI, HR, ICA,ICD, Ink,Nav, OSA,PM, SFS,SR

10.0Carbon.framework

Wrapper for including the Cocoa frameworksAppKit.framework,Foundation.framework,and CoreData.framework.

NS10.0Cocoa.framework

Contains interfaces for managing identityinformation.

CB10.5Collaboration.framework

Contains the hardware abstraction layer interfacefor manipulating audio.

Audio10.0CoreAudio.framework

Contains Objective-C interfaces for audio unitcustom views.

AU10.4CoreAudioKit.framework

Contains interfaces for managing yourapplication’s data model.

NS10.4CoreData.framework

Provides fundamental software services,including abstractions for common data types,string utilities, collection utilities, plug-in support,resource management, preferences, and XMLparsing.

CF10.0CoreFoundation.framework

Provides interfaces for determining thegeographical location of a computer.

CL10.6CoreLocation.framework

100 System Frameworks2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

APPENDIX A

Mac OS X Frameworks

Page 101: OSX Technology Overview

DescriptionPrefixesFirstavailable

Name

Contains low-level interfaces for for managingand and playing audio-visual media in anapplication.

CM10.7CoreMedia.framework

Contains interfaces of the Device AbstractionLayer (DAL) used for creating plug-ins that canaccess media hardware.

CMIO10.7CoreMediaIO.framework

Contains utilities for implementing MIDI clientprograms.

MIDI10.0CoreMIDI.framework

Contains interfaces for creating MIDI drivers tobe used by the system.

MIDI10.0CoreMIDIServer.framework

Umbrella framework for system-level services.See “Core Services Framework” (page 108).

CF, DCS, MD,SK, WS

10.0CoreServices.framework

Contains interfaces for managing video-basedcontent.

CV10.5CoreVideo.framework

Contains interfaces for managing wirelessnetworks.

CW10.6CoreWLAN.framework

Contains interfaces for displaying sharingaccount information and other identity-relatedinformation.

CB10.5Collaboration.framework

Contains interfaces for supporting network-basedlookup and directory services in your application.You can also use this framework to developdirectory service plug-ins.

ds10.0Directory-Service.framework

Contains interfaces for burning data to CDs andDVDs.

DR10.2DiscRecording.framework

Contains the user interface layer for interactingwith users during the burning of CDs and DVDs.

DR10.2DiscRecording-UI.framework

Contains interfaces for getting informationrelated to local and remote volumes.

DA10.4Disk-Arbitration.framework

Contains the game sprocket component fordrawing content to the screen.

DSp10.0DrawSprocket.framework

Contains interfaces for communicating withdigital video devices, such as video cameras.

IDH10.0DVComponent-Glue.framework

Contains interfaces for embedding DVD playbackfeatures into your application.

DVD10.3DVDPlayback.framework

Contains exception-handling classes for Cocoaapplications.

NS10.0Exception-Handling.framework

System Frameworks 1012011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

APPENDIX A

Mac OS X Frameworks

Page 102: OSX Technology Overview

DescriptionPrefixesFirstavailable

Name

Contains interfaces for communicating with forcefeedback–enabled devices.

FF10.2ForceFeedback.framework

Contains the classes and methods for the CocoaFoundation layer. If you are creating a Cocoaapplication, linking to the Cocoa framework ispreferable.

NS10.0Foundation.framework

Contains interfaces for communicating withFireWire-based audio devices.

FWA10.2FWAUserLib.framework

Contains interfaces for the OpenGL Utility Toolkit,which provides a platform-independent interfacefor managing windows.

glut, GLUT10.0GLUT.framework

Contains interfaces for Generic Security ServicesApplication Program Interface (GSSAPI).

gss10.7GSS.framework

Contains low-level interfaces for communicatingwith digital devices such as scanners andcameras. See also, “Carbon Framework” (page107).

ICD10.3ICADevices.framework

Deprecated. Use ImageCapture-Core.framework instead.

ICD10.3ImageCapture.framework

Contains Objective-C interfaces forcommunicating with digital devices such asscanners and cameras.

IC10.6ImageCapture-Core.framework

Do not use.IM10.6IMCore.framework

Contains interfaces for building third-partyplug-ins for Chat services. Umbrella frameworkfor IMServicePlugInSupport.framework.

IM10.7IMServicePlug-In.framework

Contains interfaces for developing new inputmethods, which are modules that handle textentry for complex languages.

IMK10.5InputMethodKit.framework

Contains interfaces for creating plug-ins that runduring software installation sessions.

IFX10.4Installer-Plugins.framework

Contains interfaces for obtaining the onlinestatus of an instant messaging user.

FZ, IM10.4InstantMessage.framework

Contains interfaces for communicating withBluetooth devices.

IO10.2IOBluetooth.framework

Contains the user interface layer for interactingwith users manipulating Bluetooth devices.

IO10.2IOBluetoothUI.framework

102 System Frameworks2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

APPENDIX A

Mac OS X Frameworks

Page 103: OSX Technology Overview

DescriptionPrefixesFirstavailable

Name

Contains the main interfaces for creatinguser-space device drivers and for interacting withkernel-resident drivers from user space.

IO, IOBSD,IOCF

10.0IOKit.framework

Contains low-level interfaces for sharing graphicssurfaces between applications.

IO10.6IOSurface.framework

Contains interfaces for embedding Java framesin Objective-C code.

N/A10.5JavaFrame-Embedding.framework

Contains the library and resources for executingJavaScript code within an HTML page. (Prior toMac OS X v10.5, this framework was part ofWebKit.framework.

JS10.5JavaScriptCore.framework

Contains the system’s Java Development Kitresources.

JAWT, JDWP,JMM, JNI,JVMDI,JVMPI,JVMTI

10.0JavaVM.framework

Contains interfaces for using the Kerberosnetwork authentication protocol.

GSS, KL,KRB, KRB5

10.0Kerberos.framework

Contains the interfaces for kernel-extensiondevelopment, including Mach, BSD, libkern, I/OKit, and the various families built on top of I/OKit.

numerous10.0Kernel.framework

Contains interfaces for classifying text based onlatent semantic information.

LSM10.5LatentSemantic-Mapping.framework

Do not use.N/A10.0LDAP.framework

Contains Cocoa extensions for mail delivery.AS, MF, PO,POP, RSS,TOC, UR,URL

10.0Message.framework

Contains interfaces for working with network filesystems.

NetFS10.6NetFS.framework

Contains the interfaces for OpenAL, across-platform 3D audio delivery library.

AL10.4OpenAL.framework

Contains the interfaces for distributinggeneral-purpose computational tasks across theavailable GPUs and CPUs of a computer.

CL, cl10.6OpenCL.framework

Contains Objective-C interfaces for managingOpen Directory information.

OD10.6OpenDirectory.framework

System Frameworks 1032011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

APPENDIX A

Mac OS X Frameworks

Page 104: OSX Technology Overview

DescriptionPrefixesFirstavailable

Name

Contains the interfaces for OpenGL, which is across-platform 2D and 3D graphics renderinglibrary.

CGL, GL,glu, GLU

10.0OpenGL.framework

Contains Objective-C interfaces for managingand executing OSA-compliant scripts from yourCocoa applications.

OSA10.4OSAKit.framework

Contains interfaces for interacting with smartcard devices.

MSC, Scard,SCARD

10.0PCSC.framework

Contains interfaces for implementing custommodules for the System Preferences application.

NS10.0Preference-Panes.framework

Contains interfaces for subscribing to RSS andAtom feeds.

PS10.5PubSub.framework

Contains the open source Python scriptinglanguage interfaces.

Py10.3Python.framework

Contains Objective-C interfaces for manipulatingQuickTime content.

QT10.4QTKit.framework

Umbrella framework for Quartz services. See“Quartz Framework” (page 109)

GF, PDF, QC,QCP

10.4Quartz.framework

Contains the interfaces for Core Image, CoreAnimation, and Core Video.

CA,CI, CV10.4QuartzCore.framework

Contains interfaces for generating thumbnailpreviews of documents.

QL10.5QuickLook.framework

Contains interfaces for embedding QuickTimemultimedia into your application.

N/A10.0QuickTime.framework

Contains interfaces for the Ruby scriptinglanguage.

N/A10.5Ruby.framework

Contains interfaces for running Ruby scripts fromObjective-C code.

RB10.5RubyCocoa.framework

Contains interfaces for writing screen savers.N/A10.0ScreenSaver.framework

Deprecated. Use Foundation.frameworkinstead.

NS10.0Scripting.framework

Contains interfaces for running scripts fromObjective-C code.

SB10.5Scripting-Bridge.framework

Contains interfaces for system-level userauthentication and authorization.

CSSM, Sec10.0Security.framework

104 System Frameworks2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

APPENDIX A

Mac OS X Frameworks

Page 105: OSX Technology Overview

DescriptionPrefixesFirstavailable

Name

Contains Cocoa interfaces for authorizing users.Sec10.3Security-Foundation.framework

Contains the user interface layer for authorizingusers in Cocoa applications.

PSA, SF10.3Security-Interface.framework

Contains Objective-C interfaces for sending andreceiving server-based notifications.

NS10.6Server-Notification.framework

Contains interfaces for loading, unloading andmanaging launchd services.

SM10.6Service-Management.framework

Contains the interfaces for synchronizingapplication data with a central database.

ISync10.4SyncServices.framework

Do not use.N/A10.0System.framework

Contains interfaces for accessing networkconfiguration and reachability. information.

SC10.0System-Configuration.framework

Contains interfaces for accessing the system’sTcl interpreter from an application.

Tcl10.3Tcl.framework

Contains interfaces for accessing the system’s Tktoolbox from an application.

Tk10.4Tk.framework

Contains interfaces for accessingTWAIN-compliant image-scanning hardware.

TW10.2TWAIN.framework

Deprecated. Use Accelerate.frameworkinstead. See “Accelerate Framework” (page 106).

N/A10.0vecLib.framework

Contains interfaces for using hardware resourcesfor accelerated video decoding.

VDA10.7VideoDecode-Acceleration.framework

Umbrella framework for rendering HTML content.See “WebKit Framework” (page 109).

DOM, Web10.2WebKit.framework

Contains interfaces for connecting to andmanaging computing cluster software.

XG10.4Xgrid-Foundation.framework

Contains low-level interfaces for interprocesscommunication.

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 writingsoftware, link your project against the umbrella framework; do not try to link directly to any of itssubframeworks. The following sections describe the contents of the umbrella frameworks in Mac OS X.

System Frameworks 1052011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

APPENDIX A

Mac OS X Frameworks

Page 106: OSX Technology Overview

Accelerate Framework

Table A-2 lists the subframeworks of the Accelerate framework (Accelerate.framework). If you aredeveloping applications for earlier versions of Mac OS X, vecLib.framework is available as a standaloneframework.

Table A-2 Subframeworks of the Accelerate framework

DescriptionSubframework

Contains vector-optimized interfaces for performing math, big-number, and DSPcalculations, among others.

vecLib.framework

Contains vector-optimized interfaces for manipulating image data.vImage.framework

Application Services Framework

Table A-3 lists the subframeworks of the Application Services framework(ApplicationServices.framework). These frameworks provide C-based interfaces and are intendedprimarily for Carbon applications, although other programs can use them. The listed frameworks are availablein all versions of Mac OS X unless otherwise noted.

Table A-3 Subframeworks of the Application Services framework

DescriptionSubframework

Contains interfaces for font layout and management using Apple TypeServices.

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. Availablein Mac OS X v10.5 and later.

CoreText.framework

Contains interfaces for accessibility, Internet Config, the pasteboard,the Process Manager, and the Translation Manager. Available in MacOS X 10.2 and later.

HIServices.framework

Contains interfaces for importing and exporting image data. Prior toMac 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

106 System Frameworks2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

APPENDIX A

Mac OS X Frameworks

Page 107: OSX Technology Overview

Automator Framework

Table A-4 lists the subframeworks of the Automator framework (Automator.framework).

Table A-4 Subframeworks of the Automator framework

DescriptionSubframework

Contains private interfaces for managing Automator plug-ins.MediaBrowser.framework

Carbon Framework

Table A-5 lists the subframeworks of the Carbon framework (Carbon.framework). The listed frameworksare available 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, use CoreAudio 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, HIToolbox object,and other user interface–related managers.

HIToolbox.framework

Contains interfaces for rendering HTML content. The WebKit frameworkis the preferred framework for HTML rendering. See “WebKitFramework” (page 109).

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 displaying printingdialogs and extensions.

Print.framework

Contains interfaces for displaying security-related dialogs.SecurityHI.framework

System Frameworks 1072011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

APPENDIX A

Mac OS X Frameworks

Page 108: OSX Technology Overview

DescriptionSubframework

Contains the Speech Recognition Manager interfaces.SpeechRecognition.framework

Core Services Framework

Table 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 otherwisenoted.

Table A-6 Subframeworks of the Core Services framework

DescriptionSubframework

Contains interfaces for creating and manipulating Apple events andmaking applications scriptable.

AE.framework

Contains interfaces for many legacy Carbon Managers. In Mac OSX v10.5 and later, this subframework contains the FSEvents API,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.DictionaryServices.framework

Contains interfaces for launching applications.LaunchServices.framework

Contains interfaces for managing Spotlight metadata.Metadata.framework

Contains interfaces for Open Transport and many hardware-relatedlegacy Carbon managers.

OSServices.framework

Contains interfaces for the Search Kit.SearchKit.framework

IMCore Framework

Table A-8 lists the subframeworks of the IMCore framework (IMCore.framework). This framework wasintroduced in Mac OS X version 10.6.

Table A-7 Subframeworks of the IMCore framework

DescriptionSubframework

Contains private interfaces.IMDaemonCore.framework

Contains private interfaces.IMFoundation.framework

Contains private interfaces.IMSecurityUtils.framework

108 System Frameworks2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

APPENDIX A

Mac OS X Frameworks

Page 109: OSX Technology Overview

DescriptionSubframework

Contains private interfaces.IMUtils.framework

Contains private interfaces.XMPPCore.framework

Quartz Framework

Table 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 PDF contentin windows.

PDFKit.framework

Contains Objective-C interfaces for playing Quartz Composer compositionsin an application.

QuartzComposer.framework

Contains Objective-C interfaces for managing and applying filter effectsto a graphics context. Available in Mac OS X version 10.5 and later.

QuartzFilters.framework

WebKit Framework

Table 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 an HTMLViewcontrol.

WebCore.framework

Xcode Frameworks

In 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.

Xcode Frameworks 1092011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

APPENDIX A

Mac OS X Frameworks

Page 110: OSX Technology Overview

Table A-10 Xcode frameworks

DescriptionPrefixesFirst availableFramework

Unit-testing framework for C++ code.None10.4CPlusTest.framework

Contains interfaces for writing plug-ins thatwork in Interface Builder v3.0 and later.

ib, IB10.5InterfaceBuilder-Kit.framework

Contains the interfaces for implementing unittests in Objective-C.

Sen10.4SenTestingKit.framework

System Libraries

Note 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 areidentified by 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.

110 System Libraries2011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

APPENDIX A

Mac OS X Frameworks

Page 111: OSX Technology Overview

This table describes the changes to Mac OS X Technology Overview.

NotesDate

Updated document for Mac OS X v10.7, with extensive reorganization andrewriting. 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 the AppleShareClientframework as deprecated, which it was in Mac OS X v10.5.

2008-10-15

Updated for Mac OS X v10.5. The document was also reorganized.2007-10-31

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 Software DesignGuidelines." 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 information in thisdocument previously appeared in System Overview.

2004-05-27

1112011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

REVISION HISTORY

Document Revision History

Page 112: OSX Technology Overview

1122011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

REVISION HISTORY

Document Revision History

Page 113: OSX Technology Overview

abstract type Defines, in information property lists,general characteristics of a family of documents. Eachabstract type has corresponding concrete types. Seealso 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 to givefine-grained access to file-system objects. Comparewith permissions.

action In the Automator application and framework,a modular unit that performs a discrete task, such asopening 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 other contact-relatedinformation. Mac OS X provides the Address Bookapplication for managing contact data. It also providesthe Address Book framework so that applications canprogrammatically manage the data.

address space Describes the range of memory (bothphysical and virtual) that a process uses while running.In Mac OS X, processes do not share address space.

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 copies ofthese items. Aliases are not as fragile as symbolic links

because they identify the volume and location on diskof a referenced file or folder; the file or folder can bemoved around without breaking the alias. See alsosymbolic link.

anti-aliasing A technique that smoothes theroughness in images or sound caused by aliasing.During frequency sampling, aliasing generates a false(alias) frequency along with the correct one. Withimages this produces a stair-step effect. Anti-aliasingcorrects this by adjusting pixel positions or settingpixel intensities so that there is a more gradualtransition 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 itself orto 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.

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 respond toevents. (AppKit is sometimes called Application Kit.)

application packaging Putting code and resourcesin the prescribed directory locations inside applicationbundles. “Application package” is sometimes usedsynonymously with “application bundle.”

1132011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

Glossary

Page 114: OSX Technology Overview

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.

bit depth The number of bits used to describesomething, such as the color of a pixel. Each additionalbit in a binary number doubles the possibleinformation conveyed.

bitmap A data structure that represents the positionsand 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 for managingsystem resources. The BSD portion of Mac OS X isbased on version 5 of the FreeBSD distribution.

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 flushed tothe 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 in anylanguage that supports this approach. The

best-known language today that uses the bytecodeand virtual machine approach is Java. In Java,bytecode is contained in a binary file with a .classsuffix. (Strictly speaking, bytecode means that theindividual instructions are one byte long, as opposedto PowerPC code, for example, which is four byteslong.) See also virtual machine (VM).

Carbon A legacy application environment in Mac OSX 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 Mac OSX and Mac OS 9.

CFM Code Fragment Manager, the library managerand code loader for processes based on PEF (PreferredExecutable Format) object files (in Carbon).

class In object-oriented languages such as Java andObjective-C, a prototype for a particular kind of object.A class definition declares instance variables anddefines methods for all members of the class. Objectsthat belong to the same class have the same types ofinstance variables and have access to the samemethods (including the instance variables andmethods inherited from superclasses).

Classic An application environment in Mac OS X thatlets you run non-Carbon legacy Mac OS software. Itsupports programs built for both PowerPC and68000-family chip architectures and is fully integratedwith the Finder and the other applicationenvironments.

Clipboard A per-user server (also known as thepasteboard) that enables the transfer of data betweenapplications, including the Finder. This server is sharedby all running applications and contains data that theuser has cut or copied, as well as other data that oneapplication wants to transfer to another, such as indragging operations. Data in the Clipboard isassociated with a name that indicates how it is to beused. You implement data-transfer operations withthe Clipboard using Core Foundation PasteboardServices or the Cocoa NSPasteboard class. See alsopasteboard.

Cocoa An advanced object-oriented developmentplatform in Mac OS X. Cocoa is a set of frameworksused for the rapid development of full-featured

1142011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

GLOSSARY

Page 115: OSX Technology Overview

applications in the Objective-C language. It is basedon the integration of OpenStep, Apple technologies,and Java.

code fragment In the CFM-based architecture, a codefragment is the basic unit for executable code and itsstatic data. All fragments share fundamentalproperties such as the basic structure and the methodof addressing code and data. A fragment can easilyaccess code or data contained in another fragment.In addition, fragments that export items can be sharedamong multiple clients. A code fragment is structuredaccording to the Preferred Executable 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 process forhandling. Daemons run continuously, usually in thebackground, waking only to handle their designatedrequests. For example, the httpd daemon respondsto HTTP requests for web information.

Darwin Another name for the Mac OS X coreoperating system. The Darwin kernel is equivalent tothe 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 into physicalmemory as they are needed.

device driver A component of an operating systemthat deals with getting data to and from a device, aswell 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 limiting theaccessibility of those items. A domain is segregatedfrom other domains. There are four domains: 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 code inthe 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. Usuallythe dynamic link editor binds modules into a programlazily (that is, as they are used). Thus modules notactually used during execution are never bound intothe program.

dynamic shared library A library whose code canbe shared by multiple, concurrently running programs.Programs share one physical copy of the library codeand do not require their own copies of that code. Withdynamic shared libraries, a program not only attemptsto resolve all undefined symbols at runtime, butattempts to do so only when those symbols arereferenced during program execution.

1152011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

GLOSSARY

Page 116: OSX Technology Overview

encryption The conversion of data into a form, calledciphertext, that cannot be easily understood byunauthorized people. The complementary process,decryption, converts encrypted data back into itsoriginal 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 unmapped.Hard (or page) faults occur when the page has beenswapped out to backing store. See also page; virtualmemory.

file package A directory that the Finder presents tousers 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 on mountedstorage devices of a certain volume format. A filesystem can also refer to the logical organization offiles used for storing and retrieving them. File systemsspecify conventions for naming files, storing data infiles, and specifying locations of files. See also volumeformat.

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. Filters cancontain executable or nonexecutable code. See alsoimage units.

firewall Software (or a computer running suchsoftware) that prevents unauthorized access to anetwork by users outside the network. (A physical

firewall 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. TheMac OS Standard and Extended file systems store aseparate data fork and resource fork as part of everyfile; 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 that displayimages 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, supports Unicoderepresentation of file and directory names, andsupports 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 on anetwork.

1162011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

GLOSSARY

Page 117: OSX Technology Overview

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 as Javaand Objective-C, an object that belongs to (is amember of ) a particular class. Instances are createdat runtime according to the specification in the classdefinition.

Interface Builder An application or subsystem forcreating user interfaces. You use Interface Builder tobuild and configure your user interface using a set ofstandard components and save that data to a resourcefile that can be loaded into your program at runtime.Xcode 4.0 integrates Interface Builder features; 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 involveswriting or modifying code to make use of locale-awareoperating-system services for appropriate localizedtext input, display, formatting, and manipulation. Seealso localization.

interprocess communication (IPC) A set ofprogramming interfaces that enables a process tocommunicate data or information to another process.Mechanisms for IPC exist in the different layers of thesystem, from Mach messaging in the kernel todistributed notifications and Apple events in theapplication environments. Each IPC mechanism hasits own advantages and limitations, so it is not unusualfor a program to use multiple IPC mechanisms. 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 in MacOS X. The I/O Kit framework uses a restricted form ofC++ to provide default behavior and anobject-oriented programming model for creatingcustom drivers.

iSync A tool for synchronizing Address Bookinformation.

Java A development environment for creatingapplications. Java was created by Sun Microsystems.

Java Native Interface (JNI) A technology for bridgingC-based code with Java.

Java Virtual Machine (JVM) The runtimeenvironment for executing Java code. Thisenvironment includes a just-in-time bytecodecompiler and utility code.

kernel The complete Mac OS X core operating-systemenvironment, which includes Mach, BSD, the I/O Kit,file systems, and networking components. Also calledthe kernel environment.

key An arbitrary value (usually a string) used to locatea piece of data in a data structure such as a dictionary.

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 ofuser 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 that canmodify the data during this period.

manager In Carbon, a library or set of related librariesthat define a programming interface.

1172011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

GLOSSARY

Page 118: OSX Technology Overview

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, themain thread is the first thread in the process. A userprocess can use the POSIX threading API (pthread) tocreate 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 rules bywhich 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 tophysical memory in response to page faults. Thus, thedisk file serves as backing store for the code or datanot immediately needed in physical memory.

memory protection A system of memorymanagement in which programs are prevented frombeing able to modify or corrupt the memory partitionof another program. Mac OS 9 does not have memoryprotection; 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 network packetmay be addressed to multiple recipients. Multicast isused, for example, in streaming video, in which manymegabytes of data are sent over the network.

multihoming The ability to have multiple networkaddresses in one computer. For example, multihomingmight be used to create a system in which oneaddress is used to talk to hosts outside a firewall andthe other to talk to hosts inside; the operating systemprovides facilities for passing information betweenthe 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 generated bythe Interface Builder application.

nonretained window A window without an offscreenbuffer for screen pixel values.

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” issometimes 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. Distributed notificationsprovide a way for a process to broadcast an alert(along with additional data) to any other process thatmakes itself an observer of that notification. Finally,the Notification Manager (a Carbon manager) letsbackground programs notify users—through blinkingicons in the menu bar, by sounds, or by dialogs—thattheir intercession is required.

NFS Network File System. An NFS file server allowsusers on the network to share files on other hosts asif they were on their own local disks.

object A programming unit that groups together adata structure (instance variables) and the operations(methods) that can use or affect that data. Objectsare the principal building blocks of object-orientedprograms.

1182011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

GLOSSARY

Page 119: OSX Technology Overview

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 individual fieldsof an initialized opaque type are hidden from clients,but the type’s functions offer access to most valuesof these fields. An opaque type is roughly equivalentto a class in object-oriented programming.

Open Computing Language (OpenCL) Astandards-based technology for performinggeneral-purpose computations on a computer’sgraphics processor. For more information, see OpenCLProgramming Guide for Mac OS X.

OpenGL The Open Graphics Language; anindustry-wide standard for developing portable 2Dand 3D graphics applications. OpenGL consists of anAPI and libraries that developers use to render contentin 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.

Open Transport Open Transport is a legacycommunications architecture for implementingnetwork protocols and other communication featureson computers running the Mac OS. Open Transport

provides a set of programming interfaces thatsupports, among other things, both the AppleTalkand TCP/IP protocols.

package In Java, a way of storing, organizing, andcategorizing related Java class files; typical packagenames are java.util andcom.apple.cocoa.foundation. See alsoapplication packaging.

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 backing store.As a verb, page refers to transferring pages betweenphysical 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 the filesystem. The output of the ls -l command representspermissions as a nine-position code segmented intothree binary three-character subcodes; the firstsubcode gives the permissions for the owner of thefile, the second for the group that the file belongs to,and the last for everyone else. For example,-rwxr-xr-- means that the owner of the file hasread, write, execute permissions (rwx); the group hasread and execute permissions (r-x); everyone else hasonly read permissions. The leftmost position indicateswhether this is a regular file (-), a directory (d), asymbolic link (l), or a special pseudo-file device (nocharacter). The execute bit has a different semanticfor directories, meaning they 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.

1192011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

GLOSSARY

Page 120: OSX Technology Overview

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 channel forcommunication between tasks running on a singlesystem. (2) In IP transport protocols, an integeridentifier used to select a receiver for an incomingpacket or to specify the sender of an outgoing packet.

POSIX The Portable Operating System Interface. Anoperating-system interface standardization effortsupported by ISO/IEC, IEEE, and The Open Group.

PostScript A language that describes the appearance(text and graphics) of a printed page. PostScript is anindustry standard for printing and imaging. Manyprinters contain or can be loaded with PostScriptsoftware. PostScript handles industry-standard,scalable typefaces in the Type 1 and TrueType formats.PostScript is an output format of 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. Aprocess’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 representation ofdata that uses Extensible Markup Language (XML) asthe structuring medium. Elements of a property listrepresent 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 that providehigh-quality graphics, compositing, translucency, andother effects for rendered content. Quartz is part ofthe Application Services umbrella framework.

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 import andexport 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 it containsinformation that is directly mapped to the displaygrid. A raster image is usually difficult to modifywithout loss of information. Examples of raster-imagefile types are BMP, TIFF, GIF, and JPEG files. See alsovector 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, the

1202011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

GLOSSARY

Page 121: OSX Technology Overview

computer 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 nearly simultaneously.For example, a reentrant function can beginresponding to one call, be interrupted by other calls,and complete them all with the same results as if thefunction had received and executed each call serially.

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 user interfaceobjects, and various other things. Mac OS X supportsboth Resource Manager–style resources and “per-file”resources. Localized and nonlocalized resources areput in specific places within bundles.

retained window A window with an offscreen bufferfor screen pixel values. Images are rendered into thebuffer for any portions of the window that aren’tvisible onscreen.

role An identifier of an application’s relation to adocument type. There are five roles: Editor (reads andmodifies), Viewer (can only read), Print (can only print),Shell (provides runtime services), and None (declaresinformation about type). You specify document rolesin an application’s information property list.

ROM Read-only memory, that is, memory that cannotbe 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 for athread; it also enables the delivery of events throughthese sources. In addition to registering sources, runloops can also register timers and observers. There isexactly one run loop per thread.

runtime The period of time during which a programis being executed, as opposed to compile time or loadtime. Can also refer to the runtime environment,which designates the set of conventions that arbitratehow software is generated into executable code, howcode is mapped into memory, and how functions callone another.

Safari Apple’s web browser. Safari is the default webbrowser that ships with Mac OS X.

scheduling The determination of when each processor task runs, including assignment of start times.

SCM Repository Source Code ManagementRepositories. A code database used to enable thecollaborative development of large projects bymultiple engineers. SCM repositories are managed byspecific 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 instruct anapplication or the operating system to performvarious operations. Interpreter programs translatescripts.

SDK Software Development Kit. A set of frameworks,tools, and other resources for developing applicationsand other software for a specific version of a platformsuch 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 memoryspace and to share access to files. Semaphores areone of the techniques for interprocess communicationin 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.

1212011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

GLOSSARY

Page 122: OSX Technology Overview

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 same memoryand having equal access to I/O devices, and in whichany task, including kernel tasks, can run on anyprocessor.

socket (1) In BSD-derived systems, a socket refers todifferent entities in user and kernel operations. For auser process, a socket is a file descriptor that has beenallocated using socket(2). For the kernel, a socketis the data structure that is allocated when the kernel’simplementation of the socket(2) call is made. (2)In AppleTalk protocols, a socket serves the samepurpose as a “port” in IP transport protocols.

spool To send files to a device or program (called aspooler or daemon) that puts them in a queue forlater processing. The print spooler controls output ofjobs to a printer. Other devices, such as plotters andinput devices, can also have spoolers.

subframework A public framework that packages aspecific Apple technology and is part of an umbrellaframework. Through various mechanisms, Appleprevents or discourages developers from includingor directly linking with subframeworks. See alsoumbrella 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 by Appleand installed in the file-system location for systemsoftware.

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.

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 operating systemssuch as BSD. UFS in Mac OS X is a derivative of 4.4BSDUFS. Its disk layout is not compatible with other BSDUFS implementations.

umbrella framework A system framework thatincludes and links with constituent subframeworksand other public frameworks. An umbrella framework“contains” the system software defining an applicationenvironment or a layer of system software. See alsosubframework.

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.

1222011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

GLOSSARY

Page 123: OSX Technology Overview

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 element isstored as an independent object. Another advantageof vector graphics is that the resulting image file istypically smaller than a bitmap file containing thesame image. Examples of vector-image file types arePDF, encapsulated PostScript (EPS), and SVG. See alsoraster 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 usable bysoftware. Each task has its own range of virtualaddresses, which begins at address zero. The Machoperating system makes the CPU hardware map theseaddresses onto physical memory only when necessary,using disk memory at other times. See also physicaladdress.

virtual machine (VM) A simulated computer in thatit runs on a host computer but behaves as if it werea separate computer. The Java virtual machine worksas a self-contained operating environment to run Javaapplications and applets.

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.

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 formats canspecify such things as multiple forks (HFS and HFS+),symbolic and hard links (UFS), case sensitivity offilenames, 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 actions ina particular sequence; when the workflow executes,data is piped from one action to the next until thedesired result is achieved. See action.

Xcode An integrated development environment (IDE)for creating Mac OS X software. Xcode incorporatescompiler, debugger, linker, and text editing tools intoa single package to streamline the developmentprocess.

1232011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

GLOSSARY

Page 124: OSX Technology Overview

1242011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

GLOSSARY

Page 125: OSX Technology Overview

Numerals

3D graphics 10464-bit support 81802.1x protocol 75

A

Abstract Windowing Toolkit package 84Accelerate.framework 66, 106access control lists 77accessibility

support for 32–33ACLs. See access control listsADC. See Apple Developer ConnectionAddress Book 60Address Book action plug-ins 18AddressBook.framework 99AE.framework 108agent applications 21AGL.framework 99AGP 27, 72AirPort 76AirPort Extreme 76anti-aliasing 43Apache HTTP server 23, 76AppKit.framework 34, 35, 99AppKitScripting.framework 99Apple Developer Connection (ADC) 14Apple events 74, 108Apple Type Services 106AppleScript

overview 33script language 25scripting additions 26web services 23

AppleScriptKit.framework 99AppleShareClientCore.framework 99AppleTalk Filing Protocol (AFP) 78application plug-ins 18

application sandboxing 65application services 22Application Services umbrella framework 42applications

bundling 54opening 59

ApplicationServices.framework 42, 106Aqua 29architecture

hardware 80assistive devices 33ATS.framework 106Audio queue objects 45audio queue processing tap 45Audio Toolbox 45Audio Unit 45audio

delivery 46AudioToolbox.framework 45, 100AudioUnit.framework 45, 100authentication 56, 103Authorization Services 56automatic application termination 30automatic document saving 30automatic view layout 31Automator 18, 60, 100Automator.framework 107AV Foundation 44

B

bash shell 25blocks 55Bluetooth 102Bonjour 56, 73Bootstrap Protocol (BOOTP) 75BSD

information about 15notifications 73operating system 72ports 62, 73

1252011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

Index

Page 126: OSX Technology Overview

sockets 62bundles 54, 62

C

Calendar Store 63CalendarStore.framework 63, 100Carbon.framework 107CarbonCore.framework 108CarbonSound.framework 107cascading style sheets 23, 63CD recording 51CDSA 56, 79certificates

and security 56CFNetwork 73CFNetwork.framework 108CFRunLoop 73CFSocket 73CGI 23Cocoa application layer 29Cocoa layer 12Cocoa umbrella framework 34Cocoa.framework 100Cocoa

and web services 23Application Kit framework 99bindings 35Exception Handling framework 101Foundation framework 102text 39

code signing 66, 79Collaboration.framework 63, 100, 101collection objects 62color management module 40Color Picker 107ColorSync 40ColorSync.framework 44, 106command-line tools 24Common Unix Printing System (CUPS) 40CommonCrypto library 78CommonPanels.framework 107contextual menu plug-ins 19Core Audio 19, 45–46Core Audio framework 45Core Audio Kit 45Core Data 34, 60Core Foundation

date support 62features 61networking interfaces 108

Core Graphics 42–43

Core Image 49Core Media I/O 50Core MIDI 45Core OS layer 12Core Services layer 12Core Text 39, 43, 54Core Video 51CoreAudio.framework 45, 100CoreAudioKit.framework 45, 100CoreData.framework 34, 60, 100CoreFoundation.framework 100CoreGraphics.framework 42, 106CoreLocation.framework 100CoreMedia.framework 101CoreMediaIO.framework 50, 101CoreMIDI.framework 45, 101CoreMIDIServer.framework 101CoreServices.framework 59, 108CoreText.framework 106CoreVideo.framework 101CoreWLAN.framework 101CPlusTest.framework 110cryptography 56, 78csh shell 25CSS. See cascading style sheetsCUPS 40

D

daemons 24Darwin 70Dashboard widgets 21data model management 60data synchronization 63databases 58, 63debug file formats 82Developer Reference Library 14developer tools, downloading 14device drivers 27, 72DHCP. See Dynamic Host Configuration ProtocolDictionary Services 60DictionaryServices.framework 60, 108directory services 67DirectoryService.framework 101DirectoryServices.framework 67disc recording 51DiscRecording.framework 101DiscRecordingUI.framework 101DiskArbitration.framework 67, 101distributed notifications 58–59DNS daemon 25DNS protocol 67, 75

1262011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

INDEX

Page 127: OSX Technology Overview

Document Object Model (DOM) 23, 63document versioning 31documents, opening 59DOM. See Document Object ModelDomain Name Services. See DNS protocolDrawSprocket.framework 101DVComponentGlue.framework 101DVDPlayback.framework 101DVDs

playing 51recording 51

DWARF debugging symbols 82dyld 83Dynamic Host Configuration Protocol (DHCP) 75

E

endian issues 81Ethernet 76ExceptionHandling.framework 101

F

FAT file system 78Fax support 40FIFO (first-in, first-out) special file 74file coordination 53file system events 73file system journaling 77file systems

support 77–78File Transfer Protocol (FTP) 75filename extensions 77files

long filenames 77opening 59property list 32quarantining 79

filters 19FireWire

audio interfaces 102device drivers 27

Font window 107ForceFeedback.framework 102formatter objects 54Foundation 34

features 61Foundation.framework 34, 102frameworks 17, 99–109FreeBSD 15

FSEvents API 73FTP. See File Transfer Protocolfull-screen mode 31FWAUserLib.framework 102

G

gestures 34GIMP. See GNU Image Manipulation ProgramGLUT.framework 102GNU Image Manipulation Program (GIMP) 40Grand Central Dispatch 55GSS.framework 102

H

handwriting recognition 34, 107hardware architectures 80Help documentation 35Help.framework 107HFS (Mac OS Standard format) 77HFS+ (Mac OS Extended format) 77HI Toolbox 107HIServices.framework 106HIToolbox.framework 107HotSpot Java virtual machine 84HTML, editing 63HTML

development 23display 63

HTMLRendering.framework 107HTMLView control 109HTTP 73, 75HTTPS 75Hypertext Transport Protocol (HTTP) 75

I

I/O Kit 72ICADevices.framework 51, 102ICC profiles 40iChat presence 46icons 54Identity Services 57, 63image effects 49image units 19ImageCapture.framework 102, 107ImageCaptureCore.framework 51, 102ImageIO.framework 106

1272011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

INDEX

Page 128: OSX Technology Overview

ImageKit.framework 109images

capturing 51IMCore.framework 108IMDaemonCore.framework 108IMFoundation.framework 108IMSecurityUtils.framework 108IMServicePlugIn.framework 102IMUtils.framework 109Info.plist file 32information property list files 32Ink services 34Ink.framework 107input method components 19InputMethodKit.framework 64, 102installation packages 54InstallerPlugins.framework 102Instant Message Service Plug-in framework 46InstantMessage.framework 46, 102InterfaceBuilderKit.framework 110internationalization 54Internet support 74interprocess communication (IPC) 73–74IOBluetooth.framework 102IOBluetoothUI.framework 102IOKit.framework 103IOSurface.framework 103IP aliasing 76IPSec protocol 75IPv6 protocol 75ISO 9660 format 77

J

Jar Bundler 84Java Native Interface (JNI) 84java.awt package 84Java

and web sites 23application environment 84

JavaFrameEmbedding.framework 103JavaScript 23JavaVM.framework 103javax.swing package 84JBoss 23JIT (just-in-time) bytecode compiler 84jumbo frame support 76

K

Kerberos 56Kerberos.framework 103Kernel and Device Drivers layer 12kernel events 73kernel extensions 26kernel queues 73Kernel.framework 103kevents 73Keychain Services 56, 57–58kqueues 73

L

LangAnalysis.framework 106language analysis 106LatentSemanticMapping.framework 64, 103launch items 24Launch Services 59LaunchServices.framework 59, 108LDAP. See Lightweight Directory Access ProtocolLDAP.framework 103LEAP authentication protocol 75Lightweight Directory Access Protocol (LDAP) 67, 75locale support 62localization 54

M

Mac OS Extended format (HFS+) 77Mac OS Standard format (HFS) 77Mach 70–71Mach messages 74Mach-O file format 82Macromedia Flash 23Mandatory Access Control (MAC) 79MDS authentication protocol 75Media layer 12MediaBrowser.framework 107memory

protected 71shared 74virtual 71

Message.framework 103metadata importers 20metadata technology 33Metadata.framework 59Microsoft Active Directory 67MIDI

1282011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

INDEX

Page 129: OSX Technology Overview

frameworks 101Mouse keys. See accessibilityMS-DOS 78Multihoming 76multihoming 76multitasking 71

N

Name Binding Protocol (NBP) 75named pipes 74NavigationServices.framework 107NBP. See Name Binding ProtocolNetBoot 76NetFS.framework 103NetInfo 67network diagnostics 76network file protocols 78Network File System (NFS) 78Network Kernel Extensions (NKEs) 72Network Lookup Panel 107Network Time Protocol (NTP) 75networking

features 74file protocols 78routing 76supported protocols 74

NFS. See Network File SystemNT File System (NTFS) 78NTFS 78NTP. See Network Time Protocol

O

Objective-C 83Objective-C 2.0 83Open Computing Language 67Open Directory 67Open Panel 107Open Transport 108open-source development 14OpenAL 46OpenAL.framework 46, 103OpenCL 67OpenCL.framework 103OpenDirectory.framework 103OpenGL 46, 99OpenGL Utility Toolkit 102OpenGL.framework 104OpenScripting.framework 107

OpenSSL 79OSAKit.framework 104OSServices.framework 108

P

packages 54PAP. See Printer Access Protocolpassword management 57PCI 27, 72PCIe 72PCSC.framework 104PDF (Portable Document Format) 41PDF Kit 48PDFKit.framework 109PDFView 48PEAP authentication protocol 75pen-based input 19, 107Perl 23, 25Personal Web Sharing 76PHP 23, 25pipes, BSD 74plug-ins 18–20, 62Point-to-Point Protocol (PPP) 75Point-to-Point Protocol over Ethernet (PPPoE) 75ports, BSD 62, 73POSIX 72, 80PostScript printing 41PPP. See Point-to-Point ProtocolPPPoE. See Point-to-Point Protocol over Ethernetpreemptive multitasking 71preference panes 23PreferencePane.framework 35PreferencePanes.framework 104preferences 62print preview 41Print.framework 107PrintCore.framework 106Printer Access Protocol (PAP) 75printing

dialogs 107overview 40spooling 40

Property List Editor 32property list files 32protected memory 71PubSub.framework 104Python 25Python.framework 104

1292011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

INDEX

Page 130: OSX Technology Overview

Q

QD.framework 106QTKit.framework 50, 104QuartComposer.framework 48Quartz 2D 38, 42–43Quartz Composer 48Quartz Core 48Quartz Extreme 43Quartz framework 47Quartz Services 42Quartz.framework 47, 109QuartzComposer.framework 109QuartzCore.framework 38, 40, 48, 104Quick Look 62Quick Look,preview panel 48QuickDraw 106QuickLook.framework 104QuickLookUI.framework 48QuickTime Kit 50QuickTime.framework 104

R

raster printers 41resolution independent UI 43Resume 29Routing Information Protocol 76RTP (Real-Time Transport Protocol) 37RTSP (Real-Time Streaming Protocol) 37Ruby 25Ruby.framework 104RubyCocoa.framework 104run loop support 62runtime environments 83

S

S/MIME. See Secure MIMESafari extension 20Safari plug-ins 20Save Panel 107schema 60screen readers 33screen savers 21–22ScreenSaver.framework 36, 104script languages 25–26scripting additions 26scripting support 79Scripting.framework 104

ScriptingBridge.framework 104Search Kit 59SearchKit.framework 59, 108Secure MIME (S/MIME) 75secure shell (SSH) protocol 75secure transport 56security 78

dialogs 107Kerberos 103overview 56

Security Transform 56Security.framework 56, 104SecurityFoundation.framework 105SecurityHI.framework 107SecurityInterface.framework 36, 105semaphores 74ServerNotification.framework 105Service Location Protocol 75ServiceManagement.framework 105services 22SFTP protocol 75sh shell 25sharing accounts 57Shockwave 23Simple Object Access Protocol (SOAP) 23, 75SLP. See Service Location Protocolsmart cards 104SMB/CIFS 78SOAP. See Simple Object Access Protocolsockets 62, 73Sound Manager interfaces 107Spaces 35speech recognition 32, 57speech synthesis 57SpeechRecognition.framework 108SpeechSynthesis.framework 106spelling checkers 19spoken user interface 33Spotlight importer plug-in 59Spotlight importers 20, 33Spotlight technology 33SQLite 58SSH protocol 75stabs debugging symbols 82Sticky keys. See accessibilitystreams 62, 73strings 62Swing package 84Sync Services 63SyncServices.framework 63, 105, 110System.framework 105SystemConfiguration.framework 68, 105

1302011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

INDEX

Page 131: OSX Technology Overview

T

Tcl 25Tcl.framework 105TCP. See Transmission Control Protocoltcsh shell 26threads 79Time Machine 57time support 62Tk.framework 105TLS authentication protocol 75toll-free bridging 62Tomcat 23tools, downloading 14Transmission Control Protocol (TCP) 75transparency 43trust services 56TTLS authentication protocol 75TWAIN.framework 105

U

UDF (Universal Disk Format) 77UDP. See User Datagram ProtocolUFS (UNIX File System) 78Unicode 54URLs

opening 59support for 62

User Datagram Protocol (UDP) 75user interface preservation 30

V

vecLib.framework 105, 106vector units 66Velocity Engine 43Versions 31VideoDecodeAcceleration.framework 105vImage.framework 106Virtual File System (VFS) 77virtual memory 71visual effects 49VoiceOver 33

W

weak linking 83

Web Kit 63web services 23–24Web Services Core 59WebCore.framework 109WebDAV 78WebKit.framework 105, 109WebObjects 23WebServicesCore.framework 59websites 23window layouts 54workflow, managing 18

X

X11 environment 80Xcode 4.0 14Xcode Tools, downloading 14XgridFoundation.framework 105XHTML 23XML-RPC 23, 75XML

and websites 23parsing 58, 62

XMPPCore.framework 109XPC Services 69XPC,for interprocess communication 69XPCService.framework 105XPCServices.framework 69

Z

Zero-configuration networking 76zero-configuration networking 56zooming. See accessibilityzsh shell 26

1312011-04-30 | © 2004, 2011 Apple Inc. All Rights Reserved.

INDEX