Apple events
Encyclopedia
Apple events are the canonical message-based interprocess communication mechanism in Mac OS
Mac OS
Mac OS is a series of graphical user interface-based operating systems developed by Apple Inc. for their Macintosh line of computer systems. The Macintosh user experience is credited with popularizing the graphical user interface...

, first appearing in System 7
System 7 (Macintosh)
System 7 is a single-user graphical user interface-based operating system for Macintosh computers. It was introduced on May 13, 1991 by Apple Computer. It succeeded System 6, and was the main Macintosh operating system until it was succeeded by Mac OS 8 in 1997...

 and supported by every version since then, including Mac OS X
Mac OS X
Mac OS X is a series of Unix-based operating systems and graphical user interfaces developed, marketed, and sold by Apple Inc. Since 2002, has been included with all new Macintosh computer systems...

. Apple events describe "high-level" events such as "open document" or "print file", whereas earlier OS's had supported much more basic events only, namely "click" and "keypress". Apple events form the basis of the Mac OS scripting system, AppleScript
AppleScript
AppleScript is a scripting language created by Apple Inc. and built into Macintosh operating systems since System 7. The term "AppleScript" may refer to the scripting system itself, or to particular scripts that are written in the AppleScript language....

.

The starting point is a dynamically-typed, extensible descriptor format called an AEDesc, which is just an OSType
OSType
OSType is the name of a four-byte sequence commonly used as an identifier in Mac OS. While the bytes can have any value, they usually display figures characterized in software programs such as those utilized in ASCII or Mac OS Roman character sets.OSType values are used to identify file data...

 code specifying the data type, together with a block of type-dependent data. For instance, the OSType code inte indicated that the data was a four-byte signed integer in big-endian
Endianness
In computing, the term endian or endianness refers to the ordering of individually addressable sub-components within the representation of a larger data item as stored in external memory . Each sub-component in the representation has a unique degree of significance, like the place value of digits...

 format.

Besides predefined type codes for various common simple types, there are two predefined structured descriptor types: an AERecord, which has data type reco (record), and AEList with type list (list or array). The internal structure of these contain recursively-nested AEDescs, while the AERecord also associated each element with a unique record field ID, which is an OSType. The Apple Event Manager provides API
Application programming interface
An application programming interface is a source code based specification intended to be used as an interface by software components to communicate with each other...

 calls to construct these structures, as well as extract their contents and query the type of contents they hold.

The Apple Event Manager also supports coercions, which converts AEDescs from one data type to another. In addition to standard coercions, for instance between integer and real types, applications can install their own coercion handler callbacks
Callback (computer science)
In computer programming, a callback is a reference to executable code, or a piece of executable code, that is passed as an argument to other code. This allows a lower-level software layer to call a subroutine defined in a higher-level layer....

, which could handle conversions to and from custom data types.

An Apple event proper is an AERecord with fields that depended on the purpose of the event. In addition, it has attributes (which are distinct from record fields, which are now called the parameters of the event) from a set predefined by the Apple Event Manager, specifying such things as the event type and class codes which indicates what the event is supposed to do (both OSTypes), the target address to which the event is to be sent (which could be a process on the local or a remote machine), and various other options for handling it. Remote machines initially had to be connected via AppleTalk
AppleTalk
AppleTalk is a proprietary suite of protocols developed by Apple Inc. for networking computers. It was included in the original Macintosh released in 1984, but is now unsupported as of the release of Mac OS X v10.6 in 2009 in favor of TCP/IP networking...

, but Mac OS 9
Mac OS 9
Mac OS 9 is the final major release of Apple's Mac OS before the launch of Mac OS X. Introduced on October 23, 1999, Apple positioned it as "The Best Internet Operating System Ever," highlighting Sherlock 2's Internet search capabilities, integration with Apple's free online services known as...

 added the option for connections via TCP/IP.

After sending an Apple event to its target process, the sending process could elect to receive a reply. This is also an Apple event, which could contain various bits of information returned from the target about the processing of the request event, including an error code indicating success/failure, or any other appropriate information.

Apple events are the foundation of the AppleEvent Object Model
AppleEvent Object Model
The AppleEvent Object Model was a set of protocols built on top of AppleEvents by which applications running under Mac OS could control each other's functions. Applications that implemented some part of the AEOM were called scriptable because they could be controlled via AppleScript...

, which in turn is the foundation of AppleScript
AppleScript
AppleScript is a scripting language created by Apple Inc. and built into Macintosh operating systems since System 7. The term "AppleScript" may refer to the scripting system itself, or to particular scripts that are written in the AppleScript language....

. Many other programming languages can send and receive Apple events, including C
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....

, C++
C++
C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. It is regarded as an intermediate-level language, as it comprises a combination of both high-level and low-level language features. It was developed by Bjarne Stroustrup starting in 1979 at Bell...

, Objective-C
Objective-C
Objective-C is a reflective, object-oriented programming language that adds Smalltalk-style messaging to the C programming language.Today, it is used primarily on Apple's Mac OS X and iOS: two environments derived from the OpenStep standard, though not compliant with it...

, Perl
Perl
Perl is a high-level, general-purpose, interpreted, dynamic programming language. Perl was originally developed by Larry Wall in 1987 as a general-purpose Unix scripting language to make report processing easier. Since then, it has undergone many changes and revisions and become widely popular...

, UserTalk, Ruby
Ruby (programming language)
Ruby is a dynamic, reflective, general-purpose object-oriented programming language that combines syntax inspired by Perl with Smalltalk-like features. Ruby originated in Japan during the mid-1990s and was first developed and designed by Yukihiro "Matz" Matsumoto...

 and Python
Python (programming language)
Python is a general-purpose, high-level programming language whose design philosophy emphasizes code readability. Python claims to "[combine] remarkable power with very clear syntax", and its standard library is large and comprehensive...

.

Further reading

. In particular, see Section 2.3 “Apple Events” (pages 9–13), though the history and importance of Apple Events is also discussed elsewhere in the paper.

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK