Mac Developer Library

Developer

Foundation Framework Reference NSAppleEventManager Class Reference

Options
Deployment Target:

On This Page
Language:

NSAppleEventManager

Provides a mechanism for registering handler routines for specific types of Apple events and dispatching events to those handlers. More...

Inheritance


Conforms To


Import Statement


import Foundation @import Foundation;

Availability


Available in OS X v10.0 and later.
  • Returns the single instance of NSAppleEventManager, creating it first if it doesn’t exist.

    Declaration

    Swift

    class func sharedAppleEventManager() -> NSAppleEventManager

    Objective-C

    + (NSAppleEventManager *)sharedAppleEventManager

    Import Statement

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • If an Apple event handler has been registered for the event specified by eventClass and eventID, removes it.

    Declaration

    Swift

    func removeEventHandlerForEventClass(_ eventClass: AEEventClass, andEventID eventID: AEEventID)

    Objective-C

    - (void)removeEventHandlerForEventClass:(AEEventClass)eventClass andEventID:(AEEventID)eventID

    Discussion

    Otherwise does nothing.

    Import Statement

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Registers the Apple event handler specified by handler for the event specified by eventClass and eventID.

    Declaration

    Swift

    func setEventHandler(_ handler: AnyObject, andSelector handleEventSelector: Selector, forEventClass eventClass: AEEventClass, andEventID eventID: AEEventID)

    Objective-C

    - (void)setEventHandler:(id)handler andSelector:(SEL)handleEventSelector forEventClass:(AEEventClass)eventClass andEventID:(AEEventID)eventID

    Discussion

    If an event handler is already registered for the specified event class and event ID, removes it. The signature for handler should match the following:

    • - (void)handleAppleEvent:(NSAppleEventDescriptor *)event withReplyEvent: (NSAppleEventDescriptor *)replyEvent;

    Import Statement

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Causes the Apple event specified by theAppleEvent to be dispatched to the appropriate Apple event handler, if one has been registered by calling setEventHandler:andSelector:forEventClass:andEventID:.

    Declaration

    Swift

    func dispatchRawAppleEvent(_ theAppleEvent: UnsafePointer<AppleEvent>, withRawReply theReply: UnsafeMutablePointer<AppleEvent>, handlerRefCon handlerRefCon: SRefCon) -> OSErr

    Objective-C

    - (OSErr)dispatchRawAppleEvent:(const AppleEvent *)theAppleEvent withRawReply:(AppleEvent *)theReply handlerRefCon:(SRefCon)handlerRefCon

    Discussion

    The theReply parameter always specifies a reply Apple event, never nil. However, the handler should not fill out the reply if the descriptor type for the reply event is typeNull, indicating the sender does not want a reply.

    The handlerRefcon parameter provides 4 bytes of data to the handler; a common use for this parameter is to pass a pointer to additional data.

    This method is primarily intended for Cocoa’s internal use. Note that dispatching an event means routing an event to an appropriate handler in the current application. You cannot use this method to send an event to other applications.

    Import Statement

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • The following constants should not be used and may eventually be removed.

    Declaration

    Swift

    let NSAppleEventTimeOutDefault: Double let NSAppleEventTimeOutNone: Double

    Objective-C

    extern const double NSAppleEventTimeOutDefault; extern const double NSAppleEventTimeOutNone;

    Constants

    • NSAppleEventTimeOutDefault

      NSAppleEventTimeOutDefault

      Specifies that an event-processing operation should continue until a timeout occurs based on a value determined by the Apple Event Manager (about 1 minute). Not currently used by applications.

      Available in OS X v10.0 and later.

    • NSAppleEventTimeOutNone

      NSAppleEventTimeOutNone

      Specifies that the application is willing to wait indefinitely for the current operation to complete. Not currently used by applications.

      Available in OS X v10.0 and later.

    Import Statement