You’re previewing Ry’s Cocoa Tutorial

The Pasteboard

For the most part, a Mac App runs in isolation. It doesn’t care about what other applications are doing—it’s concerned only with its own model layer, windows, documents, etc. However, there are two common scenarios when it does need to communicate with other apps:

OS X provides a pasteboard to enable this kind of inter-app communication. The pasteboard serves as a common storage facility that is accessible by all applications. To share some data, you simply write it to the pasteboard. Any other app can then retrieve this data by reading it from the pasteboard. The whole process is sort of like saving a file to disk and opening it in another application, but there are no actual files involved.

Using the pasteboard to copy and paste data between two apps

In this chapter, we’ll learn how to use Cocoa’s pasteboard API to implement custom copy-and-paste and drag-and-drop behavior.

Sorry, this is the end of the preview. To read the rest of this chapter, you’ll need to purchase Ry’s Cocoa Tutorial.

Mailing List

Sign up for my low-volume mailing list to find out when new content is released. Next up is a comprehensive Swift tutorial planned for late January.

You’ll only receive emails when new tutorials are released, and your contact information will never be shared with third parties. Click here to unsubscribe.