Services
In addition to cut, copy, and paste, Cocoa provides a nearly transparent system for applications to work together called Services. Services work with Cocoa’s concept of “selection” to provide a system for automatically sending information from one application to accomplish a specific function in another.
Services can send information, retrieve it, or do bidirectional processing. For example, say you’re looking at an article in a TextEdit file. To clip a paragraph from the article and place it in a “Sticky” on the desktop, you can simply select the paragraph and choose Services → Make Sticky, as shown in Figure 20-3.
Figure 20-3. The Services menu provides interapplication messaging without prior agreement between applications
How Services Work
Unlike most menus, the Services menu is not controlled by the application in which it appears. Instead, the content of the Services menu is controlled by the operating system.
When a user logs in, the Cocoa environment scans all of the folders listed in Table 20-2 for applications that advertise that they can handle the Services protocol. This advertisement consists of a list of the messages that the program can handle, what kinds of data types it can accept, and what kinds of data types it can return.
Get Building Cocoa Applications: A Step by Step Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.