Retired Document
Important: This document may not represent best practices for current development. Links to downloads and other resources may no longer be valid.
Introduction to Carbon-Cocoa Integration Guide
No matter which development environment you choose for developing applications—Cocoa or Carbon—you may find that the other development environment offers functionality you’d like to use in your application. Choosing the Cocoa or Carbon development environment to create new applications doesn’t restrict you to using the API defined for that environment. You can use the Carbon API from a Cocoa application or the Cocoa API from a Carbon application. This document shows you how.
There are a number of reasons you might want to integrate Cocoa and Carbon in an application, including the following:
You want to use existing code while getting the benefits of technologies offered by another framework.
You’re developing a common service that you want to make available to both Carbon and Cocoa.
It’s easier for you to do some tasks in Cocoa than in Carbon, or vice versa.
You’ve already created a terrific user interface in one environment and you want to access it from the other environment.
Your programming team consists of engineers with different skill sets—Cocoa and Carbon.
Who Should Read This Document?
This document assumes you are programming for Cocoa in Objective-C and does not discuss Java integration issues. To get the full benefit of this document, you should have experience programming in either the Cocoa or Carbon environment and you should also have some basic knowledge of the other environment. The See Also section contains a list of documents to help you gain this knowledge.
Organization of This Document
You should be familiar with a few fundamental concepts before you begin to integrate Cocoa and Carbon in the same application. These concepts are covered in the following articles:
Carbon and Cocoa User Interface Communication discusses how Mac OS X communicates user events between Carbon and Cocoa application environments.
Preprocessing Mixed-Language Code lists filename extensions you can use when you mix programming languages in a project.
Interchangeable Data Types provides information on Foundation (Cocoa) and Core Foundation (Carbon) data types you can use interchangeably.
Using Carbon and Cocoa in the Same Application provides a brief overview of how to combine Carbon and Cocoa code in an application. Includes a discussion of C-callable wrapper functions.
The concepts discussed in the preceding articles are put into practice in the sample code provided in these articles:
Using Cocoa Functionality in a Carbon Application describes how to use Cocoa functionality unrelated to the user interface in a Carbon application.
Using Carbon Functionality in a Cocoa Application describes how to use Carbon functionality unrelated to the user interface in a Cocoa application.
Using a Cocoa User Interface in a Carbon Application describes tasks you must perform to enable a Cocoa user interface to work properly in Carbon.
Using a Carbon User Interface in a Cocoa Application describes tasks you must perform to enable a Carbon user interface to work properly in Cocoa.
HICocoaView: Using Cocoa Views in Carbon Windows describes how HICocoaView, introduced in Mac OS X v10.5, makes it possible to use Cocoa views in a Carbon window.
Using Cocoa in a Navigation Services Dialog describes how Carbon applications using Navigation Services in Mac OS X v10.5 can directly access features in the Cocoa classes
NSOpenPanel
andNSSavePanel
.
See Also
For additional information on developing for Mac OS X, especially in Cocoa and Carbon, see the following documents:
Getting Started with Cocoa and Getting Started with Carbon provide a guided introduction and learning path for developers new to Cocoa and Carbon, respectively.
Tools & Languages Starting Point provides a guided introduction and learning path for developers new to Apple’s integrated development environment (IDE).
Mac Technology Overview provides an orientation to the technologies available in Mac OS X, with links to relevant documentation. Appendix A, “Mac OS X Frameworks,” lists the frameworks available to Mac OS X developers.
Advanced Memory Management Programming Guide addresses the object-ownership policy and related techniques for creating, copying, retaining, and disposing of objects.
Copyright © 2002, 2007 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2007-10-31