PFObserver

Conforms to:
Superclass:
NSObject
Declared In:

Introduction

A concrete class representing an observer that may be registered to observe changes to UI elements in a running application.

Discussion

A PFObserver object represents an observer that may be registered to observe changes to UI elements on the screen in a running application, such as a menu, window or button.

The PFObserver class implements all of the functionality of the accessibility API's AXObserverRef object. It declares a delegate method, -applicationWithIdentifier:atPath:didPostAccessibilityNotification:fromObservedUIElement:forAffectedUIElement: that a client application can implement to monitor and respond to accessibility notifications. As an alternative, it permits you to write a similar callback method using Objective-C.

In this documentation "observer" refers to a programmatic PFObserver object. Depending on context, "UI element" or "element" may refer to a programmatic PFUIElement or PFApplicationUIElement object or to the user interface object in the running application that is represented by a PFUIElement or PFApplicationUIElement object. References to a "PFUIElement object" generally include a PFApplicationUIElement object, since the PFApplicationUIElement class is a subclass of PFUIElement.

A PFObserver object can register to receive various notifications that are posted by UI elements in any running application when they change state; for example, when an application is activated or a window is closed. When an observer has registered for a notification, a client's delegate method or callback method is triggered to take any desired action in response to the change in the observed UI element. You can create multiple observers and register each of them for one or more notifications, but it is usually easier to register a single observer in an application and register it for all of the notifications of interest. Observers can be unregistered at will for individual notifications or for all of them. Observers maintain lists of all of their current registrations.

When they change state, accessibility API objects post notifications identified by a string, usually beginning with the prefix "AX" as in "AXWindowCreated". In a client application, you normally use the NSString constants declared in the NSAccessibility informal protocol (in NSAccessibility.h, in the Cocoa AppKit framework). Alternatively, you can use the corresponding CFStringRef constants declared in the accessibility API headers and cast them to NSString*, or use the string itself. Some constants are omitted from NSAccessibility.h or from the accessibility API headers; if you can't find a desired constant in one of these headers, use a constant from the other header or the string itself. Note that some constants in these headers may be marked as obsolete; use only the non-obsolete constants or their string equivalents to maximize compatibility with future releases of macOS.

Some applications implement custom UI elements. Although Apple discourages the invention of new notifications, some applications may implement custom notifications that are not part of Apple's accessibility API. This framework is written so that you can read and manipulate them, as well as Apple's built-in accessibility API notifications. You may be able to identify the strings used to identify custom notifications by reading an application's documentation or by examining the .strings files in its application bundle. The accessibility API currently offers no means to obtain a list of available notifications programmatically.

Public methods in the PFAssistive framework, unless otherwise noted, take Objective-C objects as parameters and, when they return Objective-C objects, return them autoreleased. Clients of the PFAssistive framework should not have to deal with Core Foundation objects. Unless otherwise noted, methods with return values return nil, NULL, 0, or NO in the event of an error.

Almost all standard UI element objects in Cocoa and Carbon applications come prewired to post notifications when they change state. Custom UI elements may have been written to post notifications, as well. However, there are many applications that do not use standard UI elements or that use custom elements that do not support the accessibility API. The only way to know which of an application's UI elements support the accessibility API is trial and error and, in some cases, an application's documentation.

The following notifications were introduced in OS X Mavericks 10.9: NSAccessibilityAnnouncementRequestedNotification and NSAccessibilityLayoutChangedNotification.

Before a client application can make use of this class in OS X Mavericks 10.9 or later, access must be granted to it in the Accessibility list in the Security & Privacy preference's Privacy pane in System Preferences. In OS X Mountain Lion 10.8 or earlier, the "Enable access for assistive devices" setting in the Accessibility (or Universal Access) pane of System Preferences must be turned on, or the client application must be made a trusted process through use of the accessibility API's AXMakeProcessTrusted() function. Authentication may be required.



Groups

DELEGATE ACCESSORS

Group members:

-delegate

Returns the receiver's delegate.

-setDelegate:

Sets the receiver's delegate to object.

 

INITIALIZATION

Group members:

-initForInfoWithBundleIdentifier:

Initializes and returns a newly allocated PFObserver object that uses a delegate method and includes an info dictionary with bundleIdentifier, the target application's bundle identifier.

-initForInfoWithBundleIdentifier:notificationDelegate:infoCallbackSelector:

Initializes and returns a newly allocated PFObserver object that uses a callback method that includes an info dictionary with bundleIdentifier, the target application's bundle identifier, temporary notification delegate callbackDelegate, and callback selector callback. Provides no observer management.

-initForInfoWithPath:

Initializes and returns a newly allocated PFObserver object that uses a delegate method and includes an info dictionary with path, the full path to the target application's bundle or file.

-initForInfoWithPath:notificationDelegate:infoCallbackSelector:

Initializes and returns a newly allocated PFObserver object that uses a callback method that includes an info dictionary with path, the full path to the target application's bundle or file, temporary notification delegate callbackDelegate, and callback selector callback. Provides no observer management.

-initForInfoWithPid:

Initializes and returns a newly allocated PFObserver object that includes an info dictionary with pid, the target application's BSD Unix process identification number (PID).

-initForInfoWithPid:notificationDelegate:infoCallbackSelector:

The designated initializer for the PFObserver class for an observer that uses a callback method that includes an info dictionary. Initializes and returns a newly allocated PFObserver object with pid, the target application's BSD Unix process identification number (PID), temporary notification delegate callbackDelegate, and info callback selector callback. Provides no observer management.

-initForInfoWithURL:

Initializes and returns a newly allocated PFObserver object that uses a delegate method and includes an info dictionary with url, the file URL for the target application's bundle or file.

-initForInfoWithURL:notificationDelegate:infoCallbackSelector:

Initializes and returns a newly allocated PFObserver object that uses a callback method that includes an info dictionary with url, the file URL for the target application's bundle or file, temporary notification delegate callbackDelegate, and callback selector callback. Provides no observer management.

-initWithBundleIdentifier:

Initializes and returns a newly allocated PFObserver object with bundleIdentifier, the target application's bundle identifier.

-initWithBundleIdentifier:notificationDelegate:callbackSelector:

Initializes and returns a newly allocated PFObserver object with bundleIdentifier, the target application's bundle identifier, temporary notification delegate callbackDelegate, and callback selector callback. Provides no observer management.

-initWithPath:

Initializes and returns a newly allocated PFObserver object with path, the full path to the target application's bundle or file.

-initWithPath:notificationDelegate:callbackSelector:

Initializes and returns a newly allocated PFObserver object with path, the full path to the target application's bundle or file, temporary notification delegate callbackDelegate, and callback selector callback. Provides no observer management.

-initWithPid:

Initializes and returns a newly allocated PFObserver object with pid, the target application's BSD Unix process identification number (PID).

-initWithPid:notificationDelegate:callbackSelector:

The designated initializer for the PFObserver class for an observer that uses a callback method. Initializes and returns a newly allocated PFObserver object with pid, the target application's BSD Unix process identification number (PID), temporary notification delegate callbackDelegate, and callback selector callback. Provides no observer management.

-initWithURL:

Initializes and returns a newly allocated PFObserver object with url, the file URL for the target application's bundle or file.

-initWithURL:notificationDelegate:callbackSelector:

Initializes and returns a newly allocated PFObserver object with url, the file URL for the target application's bundle or file, temporary notification delegate callbackDelegate, and callback selector callback. Provides no observer management.

-invalidate

Invalidates this PFObserver object when it is no longer needed.

-isValid

Reports whether this PFObserver object has been initialized and has not been invalidated.

+observerForInfoWithBundleIdentifier:

Convenience class method creates and returns an initialized PFObserver object that uses a delegate method and includes an info dictionary with bundleIdentifier, the target application's bundle identifier.

+observerForInfoWithBundleIdentifier:notificationDelegate:infoCallbackSelector:

Convenience class method creates and returns an initialized PFObserver object that uses a callback method that includes an info dictionary with bundleIdentifier, the target application's bundle identifier, temporary notification delegate callbackDelegate, and callback selector callback. Provides full observer management.

+observerForInfoWithPath:

Convenience class method creates and returns an initialized PFObserver object that uses a delegate method and includes an info dictionary with fullPath, the full path to the target application's bundle or file. Provides full observer management.

+observerForInfoWithPath:notificationDelegate:infoCallbackSelector:

Convenience class method creates and returns an initialized PFObserver object that uses a callback method that includes an info dictionary with fullPath, the full path to the target application's bundle or file, temporary notification delegate callbackDelegate, and callback selector callback. Provides full observer management.

+observerForInfoWithPid:

Convenience class method creates and returns an initialized PFObserver object that uses a delegate method and includes an info dictionary with pid, the target application's BSD Unix process identification number (PID). Provides full observer management.

+observerForInfoWithPid:notificationDelegate:infoCallbackSelector:

Convenience class method creates and returns an initialized PFObserver object that uses a callback method that includes an info dictionary with pid, the target application's BSD Unix process identification number (PID), temporary notification delegate callbackDelegate, and callback selector callback. Provides full observer management.

+observerForInfoWithURL:

Convenience class method creates and returns an initialized PFObserver object that uses a delegate method and includes an info dictionary with url, the file URL for the target application's bundle or file.

+observerForInfoWithURL:notificationDelegate:infoCallbackSelector:

Convenience class method creates and returns an initialized PFObserver object that uses a callback method that includes an info dictionary with url, the file URL for the target application's bundle or file, temporary notification delegate callbackDelegate, and callback selector callback. Provides full observer management.

+observerWithBundleIdentifier:

Convenience class method creates and returns an initialized PFObserver object with bundleIdentifier, the target application's bundle identifier.

+observerWithBundleIdentifier:notificationDelegate:callbackSelector:

Convenience class method creates and returns an initialized PFObserver object with bundleIdentifier, the target application's bundle identifier, temporary notification delegate callbackDelegate, and callback selector callback. Provides full observer management.

+observerWithName:

DEPRECATED. Convenience class method creates and returns an initialized PFObserver object with name, the name of the target application. Provides full observer management.

+observerWithName:notificationDelegate:callbackSelector:

DEPRECATED. Convenience class method creates and returns an initialized PFObserver object with name, the name of the target application, temporary notification delegate callbackDelegate, and callback selector callback. Provides full observer management.

+observerWithPath:

Convenience class method creates and returns an initialized PFObserver object with fullPath, the full path to the target application's bundle or file. Provides full observer management.

+observerWithPath:notificationDelegate:callbackSelector:

Convenience class method creates and returns an initialized PFObserver object with fullPath, the full path to the target application's bundle or file, temporary notification delegate callbackDelegate, and callback selector callback. Provides full observer management.

+observerWithPid:

Convenience class method creates and returns an initialized PFObserver object with pid, the target application's BSD Unix process identification number (PID). Provides full observer management.

+observerWithPid:notificationDelegate:callbackSelector:

Convenience class method creates and returns an initialized PFObserver object with pid, the target application's BSD Unix process identification number (PID), temporary notification delegate callbackDelegate, and callback selector callback. Provides full observer management.

+observerWithURL:

Convenience class method creates and returns an initialized PFObserver object with url, the file URL for the target application's bundle or file.

+observerWithURL:notificationDelegate:callbackSelector:

Convenience class method creates and returns an initialized PFObserver object with url, the file URL for the target application's bundle or file, temporary notification delegate callbackDelegate, and callback selector callback. Provides full observer management.

 

UTILITIES

Group members:

-isEqualToObserver:

Returns whether the receiving observer represents the same observer that observer represents.

 

DEBUGGING UTILITIES

Group members:

-description

Returns a string that represents the receiver.

 

CLASS UTILITY METHODS

Group members:

+observersForBundleIdentifier:

Class method returns an array of observers for the running application at url.

+observersForPath:

Class method returns an array of observers for the running application at fullPath.

+observersForPid:

Class method returns an array of observers for the running application whose BSD Unix application process identification number is pid.

+observersForURL:

Class method returns an array of observers for the running application at url.

+removeObserversForBundleIdentifier:

Class method unregisters and removes all observers for the running application at url, deallocating them if they have not been retained by the client.

+removeObserversForPath:

Class method unregisters and removes all observers for the running application at fullPath, deallocating them if they have not been retained by the client.

+removeObserversForPid:

Class method unregisters and removes all observers for the running application whose BSD Unix application process identification number is pid, deallocating them if they have not been retained by the client.

+removeObserversForURL:

Class method unregisters and removes all observers for the running application at url, deallocating them if they have not been retained by the client.

 

ACCESSORS

Group members:

-pidNumber

Returns the BSD Unix process identification number (PID) of the receiver's target application.

 

REGISTRATION

Group members:

-isRegisteredForNotification:fromElement:

Returns YES if element is registered with the receiver for notification.

-registerForNotification:fromElement:contextInfo:

Registers the receiver to observe element for notification, saving contextInfo for return in the client's callback selector, returning YES if successful.

-registrations

Returns a mutable array containing all registrations currently in effect in the receiver; that is, all registrations that the client has registered and has not unregistered using this observer.

-unregisterForAllNotifications

Unregisters the receiver to observe all elements for all notifications.

-unregisterForAllNotificationsFromElement:

Unregisters the receiver to observe element for all notifications.

-unregisterForNotification:fromElement:

Unregisters the receiver to observe element for notification.


Methods

-delegate

Returns the receiver's delegate.

-description

Returns a string that represents the receiver.

-initForInfoWithBundleIdentifier:

Initializes and returns a newly allocated PFObserver object that uses a delegate method and includes an info dictionary with bundleIdentifier, the target application's bundle identifier.

-initForInfoWithBundleIdentifier:notificationDelegate:infoCallbackSelector:

Initializes and returns a newly allocated PFObserver object that uses a callback method that includes an info dictionary with bundleIdentifier, the target application's bundle identifier, temporary notification delegate callbackDelegate, and callback selector callback. Provides no observer management.

-initForInfoWithPath:

Initializes and returns a newly allocated PFObserver object that uses a delegate method and includes an info dictionary with path, the full path to the target application's bundle or file.

-initForInfoWithPath:notificationDelegate:infoCallbackSelector:

Initializes and returns a newly allocated PFObserver object that uses a callback method that includes an info dictionary with path, the full path to the target application's bundle or file, temporary notification delegate callbackDelegate, and callback selector callback. Provides no observer management.

-initForInfoWithPid:

Initializes and returns a newly allocated PFObserver object that includes an info dictionary with pid, the target application's BSD Unix process identification number (PID).

-initForInfoWithPid:notificationDelegate:infoCallbackSelector:

The designated initializer for the PFObserver class for an observer that uses a callback method that includes an info dictionary. Initializes and returns a newly allocated PFObserver object with pid, the target application's BSD Unix process identification number (PID), temporary notification delegate callbackDelegate, and info callback selector callback. Provides no observer management.

-initForInfoWithURL:

Initializes and returns a newly allocated PFObserver object that uses a delegate method and includes an info dictionary with url, the file URL for the target application's bundle or file.

-initForInfoWithURL:notificationDelegate:infoCallbackSelector:

Initializes and returns a newly allocated PFObserver object that uses a callback method that includes an info dictionary with url, the file URL for the target application's bundle or file, temporary notification delegate callbackDelegate, and callback selector callback. Provides no observer management.

-initWithBundleIdentifier:

Initializes and returns a newly allocated PFObserver object with bundleIdentifier, the target application's bundle identifier.

-initWithBundleIdentifier:notificationDelegate:callbackSelector:

Initializes and returns a newly allocated PFObserver object with bundleIdentifier, the target application's bundle identifier, temporary notification delegate callbackDelegate, and callback selector callback. Provides no observer management.

-initWithPath:

Initializes and returns a newly allocated PFObserver object with path, the full path to the target application's bundle or file.

-initWithPath:notificationDelegate:callbackSelector:

Initializes and returns a newly allocated PFObserver object with path, the full path to the target application's bundle or file, temporary notification delegate callbackDelegate, and callback selector callback. Provides no observer management.

-initWithPid:

Initializes and returns a newly allocated PFObserver object with pid, the target application's BSD Unix process identification number (PID).

-initWithPid:notificationDelegate:callbackSelector:

The designated initializer for the PFObserver class for an observer that uses a callback method. Initializes and returns a newly allocated PFObserver object with pid, the target application's BSD Unix process identification number (PID), temporary notification delegate callbackDelegate, and callback selector callback. Provides no observer management.

-initWithURL:

Initializes and returns a newly allocated PFObserver object with url, the file URL for the target application's bundle or file.

-initWithURL:notificationDelegate:callbackSelector:

Initializes and returns a newly allocated PFObserver object with url, the file URL for the target application's bundle or file, temporary notification delegate callbackDelegate, and callback selector callback. Provides no observer management.

-invalidate

Invalidates this PFObserver object when it is no longer needed.

-isEqualToObserver:

Returns whether the receiving observer represents the same observer that observer represents.

-isRegisteredForNotification:fromElement:

Returns YES if element is registered with the receiver for notification.

-isValid

Reports whether this PFObserver object has been initialized and has not been invalidated.

+observerForInfoWithBundleIdentifier:

Convenience class method creates and returns an initialized PFObserver object that uses a delegate method and includes an info dictionary with bundleIdentifier, the target application's bundle identifier.

+observerForInfoWithBundleIdentifier:notificationDelegate:infoCallbackSelector:

Convenience class method creates and returns an initialized PFObserver object that uses a callback method that includes an info dictionary with bundleIdentifier, the target application's bundle identifier, temporary notification delegate callbackDelegate, and callback selector callback. Provides full observer management.

+observerForInfoWithPath:

Convenience class method creates and returns an initialized PFObserver object that uses a delegate method and includes an info dictionary with fullPath, the full path to the target application's bundle or file. Provides full observer management.

+observerForInfoWithPath:notificationDelegate:infoCallbackSelector:

Convenience class method creates and returns an initialized PFObserver object that uses a callback method that includes an info dictionary with fullPath, the full path to the target application's bundle or file, temporary notification delegate callbackDelegate, and callback selector callback. Provides full observer management.

+observerForInfoWithPid:

Convenience class method creates and returns an initialized PFObserver object that uses a delegate method and includes an info dictionary with pid, the target application's BSD Unix process identification number (PID). Provides full observer management.

+observerForInfoWithPid:notificationDelegate:infoCallbackSelector:

Convenience class method creates and returns an initialized PFObserver object that uses a callback method that includes an info dictionary with pid, the target application's BSD Unix process identification number (PID), temporary notification delegate callbackDelegate, and callback selector callback. Provides full observer management.

+observerForInfoWithURL:

Convenience class method creates and returns an initialized PFObserver object that uses a delegate method and includes an info dictionary with url, the file URL for the target application's bundle or file.

+observerForInfoWithURL:notificationDelegate:infoCallbackSelector:

Convenience class method creates and returns an initialized PFObserver object that uses a callback method that includes an info dictionary with url, the file URL for the target application's bundle or file, temporary notification delegate callbackDelegate, and callback selector callback. Provides full observer management.

+observersForBundleIdentifier:

Class method returns an array of observers for the running application at url.

+observersForPath:

Class method returns an array of observers for the running application at fullPath.

+observersForPid:

Class method returns an array of observers for the running application whose BSD Unix application process identification number is pid.

+observersForURL:

Class method returns an array of observers for the running application at url.

+observerWithBundleIdentifier:

Convenience class method creates and returns an initialized PFObserver object with bundleIdentifier, the target application's bundle identifier.

+observerWithBundleIdentifier:notificationDelegate:callbackSelector:

Convenience class method creates and returns an initialized PFObserver object with bundleIdentifier, the target application's bundle identifier, temporary notification delegate callbackDelegate, and callback selector callback. Provides full observer management.

+observerWithName:

DEPRECATED. Convenience class method creates and returns an initialized PFObserver object with name, the name of the target application. Provides full observer management.

+observerWithName:notificationDelegate:callbackSelector:

DEPRECATED. Convenience class method creates and returns an initialized PFObserver object with name, the name of the target application, temporary notification delegate callbackDelegate, and callback selector callback. Provides full observer management.

+observerWithPath:

Convenience class method creates and returns an initialized PFObserver object with fullPath, the full path to the target application's bundle or file. Provides full observer management.

+observerWithPath:notificationDelegate:callbackSelector:

Convenience class method creates and returns an initialized PFObserver object with fullPath, the full path to the target application's bundle or file, temporary notification delegate callbackDelegate, and callback selector callback. Provides full observer management.

+observerWithPid:

Convenience class method creates and returns an initialized PFObserver object with pid, the target application's BSD Unix process identification number (PID). Provides full observer management.

+observerWithPid:notificationDelegate:callbackSelector:

Convenience class method creates and returns an initialized PFObserver object with pid, the target application's BSD Unix process identification number (PID), temporary notification delegate callbackDelegate, and callback selector callback. Provides full observer management.

+observerWithURL:

Convenience class method creates and returns an initialized PFObserver object with url, the file URL for the target application's bundle or file.

+observerWithURL:notificationDelegate:callbackSelector:

Convenience class method creates and returns an initialized PFObserver object with url, the file URL for the target application's bundle or file, temporary notification delegate callbackDelegate, and callback selector callback. Provides full observer management.

-pidNumber

Returns the BSD Unix process identification number (PID) of the receiver's target application.

-registerForNotification:fromElement:contextInfo:

Registers the receiver to observe element for notification, saving contextInfo for return in the client's callback selector, returning YES if successful.

-registrations

Returns a mutable array containing all registrations currently in effect in the receiver; that is, all registrations that the client has registered and has not unregistered using this observer.

+removeObserversForBundleIdentifier:

Class method unregisters and removes all observers for the running application at url, deallocating them if they have not been retained by the client.

+removeObserversForPath:

Class method unregisters and removes all observers for the running application at fullPath, deallocating them if they have not been retained by the client.

+removeObserversForPid:

Class method unregisters and removes all observers for the running application whose BSD Unix application process identification number is pid, deallocating them if they have not been retained by the client.

+removeObserversForURL:

Class method unregisters and removes all observers for the running application at url, deallocating them if they have not been retained by the client.

-setDelegate:

Sets the receiver's delegate to object.

-unregisterForAllNotifications

Unregisters the receiver to observe all elements for all notifications.

-unregisterForAllNotificationsFromElement:

Unregisters the receiver to observe element for all notifications.

-unregisterForNotification:fromElement:

Unregisters the receiver to observe element for notification.


delegate


Returns the receiver's delegate.

- (nullable id <PFObserverDelegate>)delegate; 
Return Value

The receiver's delegate, an object of any type, or nil if it has no delegate.

Discussion

The only available delegate messages are -applicationWithIdentifier:atPath:didPostAccessibilityNotification:fromObservedUIElement:forAffectedUIElement: and -applicationWithIdentifier:atPath:didPostAccessibilityNotification:fromObservedUIElement:forAffectedUIElement:withInfo:, both of which are optional. They are declared in the PFObserverDelegate protocol.

See -setDelegate: for more information.


description


Returns a string that represents the receiver.

- (NSString *)description; 
Return Value

An NSString object.

Discussion

The returned string is formatted as a property list showing all notifications for all UI elements for which the observer is registered. In client code, call NSLog() and pass in the observer to see this information in the Xcode run log and debug console log.


initForInfoWithBundleIdentifier:


Initializes and returns a newly allocated PFObserver object that uses a delegate method and includes an info dictionary with bundleIdentifier, the target application's bundle identifier.

- (nullable instancetype)initForInfoWithBundleIdentifier:(nullable NSString *)bundleIdentifier; 
Parameters
bundleIdentifier

An NSString object, the application bundle's identifier.

Return Value

An initialized PFObserver object, or nil if the target application is not running.

Discussion

Use this convenience initializer to initialize a newly-allocated observer that uses a delegate method instead of a callback method and includes an info dictionary to respond to accessibility notifications.

A client application must call -setDelegate: and -registerForNotification:fromElement:contextInfo: in order to receive notifications.

See -initForInfoWithPid: for important information about creating new observer objects.

See also -initForInfoWithPath: , -initForInfoWithURL: and -initForInfoWithPid:.


initForInfoWithBundleIdentifier:notificationDelegate:infoCallbackSelector:


Initializes and returns a newly allocated PFObserver object that uses a callback method that includes an info dictionary with bundleIdentifier, the target application's bundle identifier, temporary notification delegate callbackDelegate, and callback selector callback. Provides no observer management.

- (nullable instancetype)initForInfoWithBundleIdentifier:(nullable NSString *)bundleIdentifier 
        notificationDelegate:(nullable id)callbackDelegate 
        infoCallbackSelector:(nullable SEL)callback; 
Parameters
bundleIdentifier

An NSString object, the application bundle's identifier.

callbackDelegate

An object of any type. A client application typically passes self in this parameter.

callback

The notification delegate's Objective-C selector to be invoked when a notification is received.

Return Value

An initialized PFObserver object, or nil if the target application is not running.

Discussion

Use this convenience initializer to initialize a newly-allocated application observer object that uses a callback method instead of a delegate method and includes an info dictionary to respond to accessibility notifications.

A client application must call -registerForNotification:fromElement:contextInfo: in order to receive notifications.

See the designated initializer -initWithPid:notificationDelegate:callbackSelector: for important information about creating new observer objects.

See also -initForInfoWithPath:notificationDelegate:infoCallbackSelector: , -initForInfoWithURL:notificationDelegate:infoCallbackSelector: and -initForInfoWithPid:notificationDelegate:infoCallbackSelector:.


initForInfoWithPath:


Initializes and returns a newly allocated PFObserver object that uses a delegate method and includes an info dictionary with path, the full path to the target application's bundle or file.

- (nullable instancetype)initForInfoWithPath:(nullable NSString *)fullPath; 
Parameters
fullPath

An NSString object giving the full path to the client application file.

Return Value

An initialized PFObserver object, or nil if the target application is not running.

Discussion

Use this convenience initializer to initialize a newly-allocated observer that uses a delegate method instead of a callback method and includes an info dictionary to respond to accessibility notifications.

A client application must call -setDelegate: and -registerForNotification:fromElement:contextInfo: in order to receive notifications.

See -initForInfoWithPid: for important information about creating new observer objects.

See also -initForInfoWithURL: , -initForInfoWithBundleIdentifier: and -initForInfoWithPid:.


initForInfoWithPath:notificationDelegate:infoCallbackSelector:


Initializes and returns a newly allocated PFObserver object that uses a callback method that includes an info dictionary with path, the full path to the target application's bundle or file, temporary notification delegate callbackDelegate, and callback selector callback. Provides no observer management.

- (nullable instancetype)initForInfoWithPath:(nullable NSString *)fullPath 
        notificationDelegate:(nullable id)callbackDelegate 
        infoCallbackSelector:(nullable SEL)callback; 
Parameters
fullPath

An NSString object giving the full path to the client application file.

callbackDelegate

An object of any type. A client application typically passes self in this parameter.

callback

The notification delegate's Objective-C selector to be invoked when a notification is received.

Return Value

An initialized PFObserver object, or nil if the target application is not running.

Discussion

Use this convenience initializer or the designated initializer -initWithPid:notificationDelegate:callbackSelector: to initialize a newly-allocated application observer object that uses a callback method instead of a delegate method and includes an info dictionary to respond to accessibility notifications. A client application must call -registerForNotification:fromElement:contextInfo: in order to receive notifications. See the designated initializer -initWithPid:notificationDelegate:callbackSelector: for important information about creating new observer objects.

See also -initForInfoWithURL:notificationDelegate:infoCallbackSelector: , -initForInfoWithBundleIdentifier:notificationDelegate:infoCallbackSelector: and -initForInfoWithPid:notificationDelegate:infoCallbackSelector:.


initForInfoWithPid:


Initializes and returns a newly allocated PFObserver object that includes an info dictionary with pid, the target application's BSD Unix process identification number (PID).

- (nullable instancetype)initForInfoWithPid:(pid_t)pid; 
Parameters
pid

An integer, the running application's BSD Unix process identification number (PID).

Return Value

An initialized PFObserver object, or nil if the target application is not running.

Discussion

Use this initializer to initialize a newly-allocated application observer object that uses a delegate method instead of a callback method and includes an info dictionary to respond to accessibility notifications.

A client application must call -setDelegate: and -registerForNotification:fromElement:contextInfo: in order to receive notifications.

A client application normally creates new PFObserver objects without using this method directly, instead using the +observerWithPath: , +observerWithURL: , +observerWithBundleIdentifier: or +observerWithPid: class method. The class methods are strongly preferred because they set up private data structures that automatically manage observers.

An observer does nothing unless it has been registered to receive at least one notification with respect to at least one observed UI element of the target application, using -registerForNotification:fromElement:contextInfo:. There can be multiple observers for any one target application, but it is normally sufficient to create one observer per target application and register it for multiple notifications. If you use one of the PFObserver factory methods, such as the +observerWithURL: class method, to create an observer, the observer is managed for you.

When an observer receives a notification from an observed element, it sends the -applicationWithIdentifier:atPath:didPostAccessibilityNotification:fromObservedUIElement:forAffectedUIElement:withInfo: delegate message, passing the target application's identifier and path, the notification, the observed UI element, the affected UI element (which may differ from the element being observed), and the notification info dictionary.

The client's delegate method will always receive the affected element, even when observing NSAccessibilityUIElementDestroyedNotification. However, you must treat a destroyed element as invalid; do not pass it as a parameter to methods that call accessibility API functions. You can, however, use a destroyed element with PFUIElement's -pid, and with PFUIElement's -isEqual: and -isEqualToElement: to manage any element cache you maintain. Note that attempting to pass a destroyed UI element in an accessibility API function is not guaranteed to return an accessibility API error. PFUIElement's -elementInfo method will return some valid information about a destroyed element.

If a delegate method initiates a time-consuming operation or an operation that might fail, consider executing the operation in a secondary thread using a method like NSThread's +detachNewThreadSelector:toTarget:withObject: method to avoid blocking the application. On the other hand, if a callback method runs an AppleScript script using a method like NSAppleScript's -executeAndReturnError: (or the preferred method, OSAScript's -executeAndReturnError:, in the OSAKit framework), always execute the operation using NSObject's -performSelectorOnMainThread:withObject:waithUntilDone: method with wait set to NO, because AppleScript scripts must run on the main application thread if they involve user interaction, as with the 'display dialog' command. AppleScript queues scripts on the main application thread in first-in, first-out (FIFO) order.

All observers maintain a list of the notifications and elements for which they are currently registered. See -registrations for details.

See also -initForInfoWithPath: , -initForInfoWithURL: and -initForInfoWithBundleIdentifier:.


initForInfoWithPid:notificationDelegate:infoCallbackSelector:


The designated initializer for the PFObserver class for an observer that uses a callback method that includes an info dictionary. Initializes and returns a newly allocated PFObserver object with pid, the target application's BSD Unix process identification number (PID), temporary notification delegate callbackDelegate, and info callback selector callback. Provides no observer management.

- (nullable instancetype)initForInfoWithPid:(pid_t)pid 
        notificationDelegate:(nullable id)callbackDelegate 
        infoCallbackSelector:(nullable SEL)callback NS_DESIGNATED_INITIALIZER; 
Parameters
pid

An integer, the running application's BSD Unix process identification number (PID).

callbackDelegate

An object of any type. A client typically passes self in this parameter.

callback

The notification delegate's Objective-C selector to be invoked when a notification is received.

Return Value

An initialized PFObserver object, or nil if the target application is not running.

Discussion

Use this designated initializer to initialize a newly-allocated application observer object that uses an info callback method instead of a delegate method and includes an info dictionary to respond to accessibility notifications.

This method covers the AXObserverCreateWithInfoCallback function introduced in Mac OS X 10.7 (Lion) and first made public in OS X Mavericks 10.9.

This method is identical to -initWithPid:notificationDelegate:callbackSelector: except that, instead of using a normal callback selector, it uses an enhanced callback selector returning an info dictionary provided by certain notifications. Applications may post notifications that include an info dictionary. The new NSAccessibilityLayoutChangedNotification notification may be posted by an application that uses the new AXShowAlternateUI and AXShowDefaultUI actions to show or hide transient UI elements, and the new NSAccessibilityAnnouncementRequestedNotification notification may be posted by an application to request that an announcement be made to the user by an assistive application such as VoiceOver. The info dictionary in the former notification contains an array listing the UI elements that have changed for the key NSAccessibilityLayoutChangedNotification. The info dictionary in the latter notification contains the announcement as a localized string for the key NSAccessibilityAnnouncementRequestedNotification.

When an observer receives one of these notifications from an observed element, it invokes the specified info callback selector on the notification delegate. It passes back to the client's callback method the observer, the notification, the affected UI element (which may differ from the element being observed), the info dictionary provided by the notification, and any context information that was provided by the client when it registered the observer for the notification. The client's callback selector should have the following signature:

- (void)observer:(PFObserver *)observer notification:(NSString *)notification element:(PFUIElement *)element notificationInfo:(NSDictionary *)notificationInfo contextInfo:(void *)contextInfo

See -initWithPid:notificationDelegate:callbackSelector: for more information.


initForInfoWithURL:


Initializes and returns a newly allocated PFObserver object that uses a delegate method and includes an info dictionary with url, the file URL for the target application's bundle or file.

- (nullable instancetype)initForInfoWithURL:(nullable NSURL *)url; 
Parameters
url

An NSURL object referencing the application.

Return Value

An initialized PFObserver object, or nil if the target application is not running.

Discussion

Use this convenience initializer to initialize a newly-allocated observer that uses a delegate method instead of a callback method and includes an info dictionary to respond to accessibility notifications.

A client application must call -setDelegate: and -registerForNotification:fromElement:contextInfo: in order to receive notifications.

See -initForInfoWithPid: for important information about creating new observer objects.

See also -initForInfoWithPath: , -initForInfoWithBundleIdentifier: and -initForInfoWithPid:.


initForInfoWithURL:notificationDelegate:infoCallbackSelector:


Initializes and returns a newly allocated PFObserver object that uses a callback method that includes an info dictionary with url, the file URL for the target application's bundle or file, temporary notification delegate callbackDelegate, and callback selector callback. Provides no observer management.

- (nullable instancetype)initForInfoWithURL:(nullable NSURL *)url 
        notificationDelegate:(nullable id)callbackDelegate 
        infoCallbackSelector:(nullable SEL)callback; 
Parameters
url

An NSURL object referencing the application.

callbackDelegate

An object of any type. A client application typically passes self in this parameter.

callback

The notification delegate's Objective-C selector to be invoked when a notification is received.

Return Value

An initialized PFObserver object, or nil if the target application is not running.

Discussion

Use this convenience initializer to initialize a newly-allocated application observer object that uses a callback method instead of a delegate method and includes an info dictionary to respond to accessibility notifications.

A client application must call -registerForNotification:fromElement:contextInfo: in order to receive notifications.

See the designated initializer -initWithPid:notificationDelegate:callbackSelector: for important information about creating new observer objects.

See also -initForInfoWithPath:notificationDelegate:infoCallbackSelector: , -initForInfoWithBundleIdentifier:notificationDelegate:infoCallbackSelector: and -initForInfoWithPid:notificationDelegate:infoCallbackSelector:.


initWithBundleIdentifier:


Initializes and returns a newly allocated PFObserver object with bundleIdentifier, the target application's bundle identifier.

- (nullable instancetype)initWithBundleIdentifier:(nullable NSString *)bundleIdentifier; 
Parameters
bundleIdentifier

An NSString object, the application bundle's identifier.

Return Value

An initialized PFObserver object, or nil if the target application is not running.

Discussion

Use this convenience initializer to initialize a newly-allocated observer that uses a delegate method instead of a callback method to respond to accessibility notifications.

A client application must call -setDelegate: and -registerForNotification:fromElement:contextInfo: in order to receive notifications.

See -initWithPid: for important information about creating new observer objects.

See also -initWithPath: , -initWithURL: and -initWithPid:.


initWithBundleIdentifier:notificationDelegate:callbackSelector:


Initializes and returns a newly allocated PFObserver object with bundleIdentifier, the target application's bundle identifier, temporary notification delegate callbackDelegate, and callback selector callback. Provides no observer management.

- (nullable instancetype)initWithBundleIdentifier:(nullable NSString *)bundleIdentifier 
        notificationDelegate:(nullable id)callbackDelegate 
        callbackSelector:(nullable SEL)callback; 
Parameters
bundleIdentifier

An NSString object, the application bundle's identifier.

callbackDelegate

An object of any type. A client application typically passes self in this parameter.

callback

The notification delegate's Objective-C selector to be invoked when a notification is received.

Return Value

An initialized PFObserver object, or nil if the target application is not running.

Discussion

Use this convenience initializer to initialize a newly-allocated application observer object that uses a callback method instead of a delegate method to respond to accessibility notifications.

A client application must call -registerForNotification:fromElement:contextInfo: in order to receive notifications.

See the designated initializer -initWithPid:notificationDelegate:callbackSelector: for important information about creating new observer objects.

See also -initWithPath:notificationDelegate:callbackSelector: , -initWithURL:notificationDelegate:callbackSelector: and -initWithPid:notificationDelegate:callbackSelector:.


initWithPath:


Initializes and returns a newly allocated PFObserver object with path, the full path to the target application's bundle or file.

- (nullable instancetype)initWithPath:(nullable NSString *)fullPath; 
Parameters
fullPath

An NSString object giving the full path to the client application file.

Return Value

An initialized PFObserver object, or nil if the target application is not running.

Discussion

Use this convenience initializer to initialize a newly-allocated observer that uses a delegate method instead of a callback method to respond to accessibility notifications.

A client application must call -setDelegate: and -registerForNotification:fromElement:contextInfo: in order to receive notifications.

See -initWithPid: for important information about creating new observer objects.

See also -initWithURL: , -initWithBundleIdentifier: and -initWithPid:.


initWithPath:notificationDelegate:callbackSelector:


Initializes and returns a newly allocated PFObserver object with path, the full path to the target application's bundle or file, temporary notification delegate callbackDelegate, and callback selector callback. Provides no observer management.

- (nullable instancetype)initWithPath:(nullable NSString *)fullPath 
        notificationDelegate:(nullable id)callbackDelegate 
        callbackSelector:(nullable SEL)callback; 
Parameters
fullPath

An NSString object giving the full path to the client application file.

callbackDelegate

An object of any type. A client application typically passes self in this parameter.

callback

The notification delegate's Objective-C selector to be invoked when a notification is received.

Return Value

An initialized PFObserver object, or nil if the target application is not running.

Discussion

Use this convenience initializer or the designated initializer -initWithPid:notificationDelegate:callbackSelector: to initialize a newly-allocated application observer object that uses a callback method instead of a delegate method to respond to accessibility notifications. A client application must call -registerForNotification:fromElement:contextInfo: in order to receive notifications. See the designated initializer -initWithPid:notificationDelegate:callbackSelector: for important information about creating new observer objects.

See also -initWithURL:notificationDelegate:callbackSelector: , -initWithBundleIdentifier:notificationDelegate:callbackSelector: and -initWithPid:notificationDelegate:callbackSelector:.


initWithPid:


Initializes and returns a newly allocated PFObserver object with pid, the target application's BSD Unix process identification number (PID).

- (nullable instancetype)initWithPid:(pid_t)pid; 
Parameters
pid

An integer, the running application's BSD Unix process identification number (PID).

Return Value

An initialized PFObserver object, or nil if the target application is not running.

Discussion

Use this convenience initializer to initialize a newly-allocated application observer object that uses a delegate method instead of a callback method to respond to accessibility notifications.

A client application must call -setDelegate: and -registerForNotification:fromElement:contextInfo: in order to receive notifications.

A client application normally creates new PFObserver objects without using an initializer method directly, instead using the +observerWithPath: , +observerWithURL: , +observerWithBundleIdentifier: or +observerWithPid: class factory method. The class methods are strongly preferred because they set up private data structures that automatically manage observers.

An observer does nothing unless it has been registered to receive at least one notification with respect to at least one observed UI element of the target application, using -registerForNotification:fromElement:contextInfo:. There can be multiple observers for any one target application, but it is normally sufficient to create one observer per target application and register it for multiple notifications. If you use one of the PFObserver factory methods, such as the +observerWithURL: class method, to create an observer, the observer is managed for you.

When an observer receives a notification from an observed element, it sends the -applicationWithIdentifier:atPath:didPostAccessibilityNotification:fromObservedUIElement:forAffectedUIElement: delegate message, passing the target application's identifier and path, the notification, the observed UI element, and the affected UI element (which may differ from the element being observed).

The client's delegate method will always receive the affected element, even when observing NSAccessibilityUIElementDestroyedNotification. However, you must treat a destroyed element as invalid; do not pass it as a parameter to methods that call accessibility API functions. You can, however, use a destroyed element with PFUIElement's -pid, and with PFUIElement's -isEqual: and -isEqualToElement: to manage any element cache you maintain. Note that attempting to pass a destroyed UI element in an accessibility API function is not guaranteed to return an accessibility API error. PFUIElement's -elementInfo method will return some valid information about a destroyed element.

If a delegate method initiates a time-consuming operation or an operation that might fail, consider executing the operation in a secondary thread using a method like NSThread's +detachNewThreadSelector:toTarget:withObject: method to avoid blocking the application. On the other hand, if a callback method runs an AppleScript script using a method like NSAppleScript's -executeAndReturnError: (or the preferred method, OSAScript's -executeAndReturnError:, in the OSAKit framework), always execute the operation using NSObject's -performSelectorOnMainThread:withObject:waithUntilDone: method with wait set to NO, because AppleScript scripts must run on the main application thread if they involve user interaction, as with the 'display dialog' command. AppleScript queues scripts on the main application thread in first-in, first-out (FIFO) order.

All observers maintain a list of the notifications and elements for which they are currently registered. See -registrations for details.

See also -initWithPath: , -initWithURL: and -initWithBundleIdentifier:.


initWithPid:notificationDelegate:callbackSelector:


The designated initializer for the PFObserver class for an observer that uses a callback method. Initializes and returns a newly allocated PFObserver object with pid, the target application's BSD Unix process identification number (PID), temporary notification delegate callbackDelegate, and callback selector callback. Provides no observer management.

- (nullable instancetype)initWithPid:(pid_t)pid 
        notificationDelegate:(nullable id)callbackDelegate 
        callbackSelector:(nullable SEL)callback NS_DESIGNATED_INITIALIZER; 
Parameters
pid

An integer, the running application's BSD Unix process identification number (PID).

callbackDelegate

An object of any type. A client typically passes self in this parameter.

callback

The notification delegate's Objective-C selector to be invoked when a notification is received.

Return Value

An initialized PFObserver object, or nil if the target application is not running.

Discussion

Use this designated initializer to initialize a newly-allocated application observer object that uses a callback method instead of a delegate method to respond to accessibility notifications.

This method covers the AXObserverCreate function.

Although this is a designated initializer for the PFObserver class, a client application normally creates new PFObserver objects without using this method directly, instead using the +observerWithPath:notificationDelegate:callbackSelector: , +observerWithURL:notificationDelegate:callbackSelector: , +observerWithBundleIdentifier:notificationDelegate:callbackSelector: or the +observerWithPid:notificationDelegate:callbackSelector: class method. The class methods are strongly preferred because they set up private data structures that automatically manage observers.

An observer does nothing unless it has been registered to receive at least one notification with respect to at least one observed UI element of the target application, using -registerForNotification:fromElement:contextInfo:. There can be multiple observers for any one target application, but it is normally sufficient to create one observer per target application and register it for multiple notifications. If you use one of the PFObserver factory methods, such as the +observerWithURL:notificationDelegate:callbackSelector: class method to create an observer, the observer is managed for you.

When an observer receives a notification from an observed element, it invokes the specified callback selector on the notification delegate. It passes back to the client's callback method the observer, the notification, the affected UI element (which may differ from the element being observed), and any context information that was provided by the client when it registered the observer for the notification. A notification delegate is temporary; the relationship only lasts until the observer is deallocated. The client's callback selector should have the following signature:

- (void)observer:(PFObserver *)observer notification:(NSString *)notification element:(PFUIElement *)element contextInfo:(void *)contextInfo

The client's callback method will always receive the affected element, even when observing NSAccessibilityUIElementDestroyedNotification. However, you must treat a destroyed element as invalid; do not pass it as a parameter to methods that call accessibility API functions. You can, however, use a destroyed element with PFUIElement's -pid, and with PFUIElement's -isEqual: and -isEqualToElement: to manage any element cache you maintain. Note that attempting to pass a destroyed UI element in an accessibility API function is not guaranteed to return an accessibility API error. PFUIElement's -elementInfo method will return some valid information about a destroyed element.

If a callback method initiates a time-consuming operation or an operation that might fail, consider executing the operation in a secondary thread using a method like NSThread's +detachNewThreadSelector:toTarget:withObject: method to avoid blocking the application. On the other hand, if a callback method runs an AppleScript script using a method like NSAppleScript's -executeAndReturnError: (or the preferred method, OSAScript's -executeAndReturnError:, in the OSAKit framework), always execute the operation using NSObject's -performSelectorOnMainThread:withObject:waithUntilDone: method with wait set to NO, because AppleScript scripts must run on the main application thread if they involve user interaction, as with the 'display dialog' command. AppleScript queues scripts on the main application thread in first-in, first-out (FIFO) order.

All observers maintain a list of the notifications and elements for which they are currently registered. See -registrations for details.

If you allocate your own observer and use this method to initialize it, you must manage the observer yourself. It is the client's responsibility to keep track of each observer created in this manner, retaining it as long as it is in use; to register and unregister it for notifications and elements as desired; to release it when done with it; and to maintain a list of its current registrations.

See also -initWithPath:notificationDelegate:callbackSelector:, -initWithURL:notificationDelegate:callbackSelector: and -initWithBundleIdentifier:notificationDelegate:callbackSelector:.


initWithURL:


Initializes and returns a newly allocated PFObserver object with url, the file URL for the target application's bundle or file.

- (nullable instancetype)initWithURL:(nullable NSURL *)url; 
Parameters
url

An NSURL object referencing the application.

Return Value

An initialized PFObserver object, or nil if the target application is not running.

Discussion

Use this convenience initializer to initialize a newly-allocated observer that uses a delegate method instead of a callback method to respond to accessibility notifications.

A client application must call -setDelegate: and -registerForNotification:fromElement:contextInfo: in order to receive notifications.

See -initWithPid: for important information about creating new observer objects.

See also -initWithPath: , -initWithBundleIdentifier: and -initWithPid:.


initWithURL:notificationDelegate:callbackSelector:


Initializes and returns a newly allocated PFObserver object with url, the file URL for the target application's bundle or file, temporary notification delegate callbackDelegate, and callback selector callback. Provides no observer management.

- (nullable instancetype)initWithURL:(nullable NSURL *)url 
        notificationDelegate:(nullable id)callbackDelegate 
        callbackSelector:(nullable SEL)callback; 
Parameters
url

An NSURL object referencing the application.

callbackDelegate

An object of any type. A client application typically passes self in this parameter.

callback

The notification delegate's Objective-C selector to be invoked when a notification is received.

Return Value

An initialized PFObserver object, or nil if the target application is not running.

Discussion

Use this convenience initializer to initialize a newly-allocated application observer object that uses a callback method instead of a delegate method to respond to accessibility notifications.

A client application must call -registerForNotification:fromElement:contextInfo: in order to receive notifications.

See the designated initializer -initWithPid:notificationDelegate:callbackSelector: for important information about creating new observer objects.

See also -initWithPath:notificationDelegate:callbackSelector: , -initWithBundleIdentifier:notificationDelegate:callbackSelector: and -initWithPid:notificationDelegate:callbackSelector:.


invalidate


Invalidates this PFObserver object when it is no longer needed.

- (void)invalidate; 
Discussion

Optionally call this method when the client application is finished with this PFObserver object.

Call this method as soon as this PFObserver object is no longer needed in order to avoid adding time-consuming activity at dealloc time. If the client application does not call this method, it will be called automatically when the object is deallocated. It sets any delegate to nil and takes care of memory management.

NOTE: PFAssistive Framework does not support garbage collected clients.

See also -isValid.


isEqualToObserver:


Returns whether the receiving observer represents the same observer that observer represents.

- (BOOL)isEqualToObserver:(PFObserver *)observer; 
Parameters
observer

A PFObserver object to be tested for equality with the receiver.

Discussion

Returns YES if the receiving observer represents the same observer that observer represents.

Use this method for efficiency if you know that observer is a PFObserver object. Otherwise, use -isEqual:.


isRegisteredForNotification:fromElement:


Returns YES if element is registered with the receiver for notification.

- (BOOL)isRegisteredForNotification:(NSString *)notification 
        fromElement:(nullable PFUIElement *)element; 
Parameters
notification

An NSString representing a notification; you may use a string constant from the NSAccessibility informal protocol or from the accessibility API's AXConstants.h header file cast to NSString*, or the string itself.

element

A PFUIElement object.

Discussion

Returns YES if the receiver is registered for notification from element.

Use this method at any time to test whether a particular element is registered with the receiver for a particular notification. It always returns NO for an element that does not support the specified notification.

See also -registerForNotification:fromElement:contextInfo:, -unregisterForNotification:fromElement:, -unregisterForAllNotificationsFromElement: and -unregisterForAllNotifications.


isValid


Reports whether this PFObserver object has been initialized and has not been invalidated.

- (BOOL)isValid; 
Discussion

Returns YES once this PFUIElement object has been initialized, or NO once it has been invalidated.

See also -invalidate.


observerForInfoWithBundleIdentifier:


Convenience class method creates and returns an initialized PFObserver object that uses a delegate method and includes an info dictionary with bundleIdentifier, the target application's bundle identifier.

+ (nullable instancetype)observerForInfoWithBundleIdentifier:(nullable NSString *)bundleIdentifier; 
Parameters
bundleIdentifier

An NSString object, the application bundle's identifier.

Return Value

An autoreleased PFObserver object, or nil if the target application is not running.

Discussion

Use this convenience method to create an observer that uses a delegate method instead of a callback method and includes an info dictionary to respond to accessibility notifications.

A client application must call -setDelegate: and -registerForNotification:fromElement:contextInfo: in order to receive notifications.

See -initForInfoWithPid: for important information about creating new observer objects.

See also +observerForInfoWithPath: , +observerForInfoWithURL: and +observerForInfoWithPid:.


observerForInfoWithBundleIdentifier:notificationDelegate:infoCallbackSelector:


Convenience class method creates and returns an initialized PFObserver object that uses a callback method that includes an info dictionary with bundleIdentifier, the target application's bundle identifier, temporary notification delegate callbackDelegate, and callback selector callback. Provides full observer management.

+ (nullable instancetype)observerForInfoWithBundleIdentifier:(nullable NSString *)bundleIdentifier 
        notificationDelegate:(nullable id)callbackDelegate 
        infoCallbackSelector:(nullable SEL)callback; 
Parameters
bundleIdentifier

An NSString object, the application bundle's identifier.

callbackDelegate

An object of any type. A client typically passes self in this parameter.

callback

The notification delegate's Objective-C selector to be invoked when a notification is received.

Return Value

An autoreleased PFObserver object, or nil if the target application is not running.

Discussion

Use this method to create an observer for a specific application given its name and to set up automatic management of the observer, for an observer that uses a callback method instead of a delegate method and includes an info dictionary to respond to accessibility notifications.

See the designated initializer, -initForInfoWithPid:notificationDelegate:infoCallbackSelector:, for full information about use of this method.

See also +observerForInfoWithPath:notificationDelegate:infoCallbackSelector: , +observerForInfoWithURL:notificationDelegate:infoCallbackSelector: and +observerForInfoWithPid:notificationDelegate:infoCallbackSelector:.


observerForInfoWithPath:


Convenience class method creates and returns an initialized PFObserver object that uses a delegate method and includes an info dictionary with fullPath, the full path to the target application's bundle or file. Provides full observer management.

+ (nullable instancetype)observerForInfoWithPath:(nullable NSString *)fullPath; 
Parameters
fullPath

An NSString object giving the full path to the application.

Return Value

An autoreleased PFObserver object, or nil if the target application is not running.

Discussion

Use this convenience method to create an observer that uses a delegate method instead of a callback method and includes an info dictionary to respond to accessibility notifications.

A client application must call -setDelegate: and -registerForNotification:fromElement:contextInfo: in order to receive notifications.

See -initForInfoWithPid: for important information about creating new observer objects.

See also +observerForInfoWithURL: , +observerForInfoWithBundleIdentifier: and +observerForInfoWithPid:.


observerForInfoWithPath:notificationDelegate:infoCallbackSelector:


Convenience class method creates and returns an initialized PFObserver object that uses a callback method that includes an info dictionary with fullPath, the full path to the target application's bundle or file, temporary notification delegate callbackDelegate, and callback selector callback. Provides full observer management.

+ (nullable instancetype)observerForInfoWithPath:(nullable NSString *)fullPath 
        notificationDelegate:(nullable id)callbackDelegate 
        infoCallbackSelector:(nullable SEL)callback; 
Parameters
fullPath

An NSString object giving the full path to the application.

callbackDelegate

An object of any type. A client typically passes self in this parameter.

callback

The notification delegate's Objective-C selector to be invoked when a notification is received.

Return Value

An autoreleased PFObserver object, or nil if the target application is not running.

Discussion

Use this method to create an observer for a specific application given its name and to set up automatic management of the observer, for an observer that uses a callback method instead of a delegate method and includes an info dictionary to respond to accessibility notifications.

See the designated initializer, -initForInfoWithPid:notificationDelegate:infoCallbackSelector:, for full information about use of this method.

See also +observerForInfoWithURL:notificationDelegate:infoCallbackSelector: , +observerForInfoinitWithBundleIdentifier:notificationDelegate:infoCallbackSelector: and +observerForInfoWithPid:notificationDelegate:infoCallbackSelector:.


observerForInfoWithPid:


Convenience class method creates and returns an initialized PFObserver object that uses a delegate method and includes an info dictionary with pid, the target application's BSD Unix process identification number (PID). Provides full observer management.

+ (nullable instancetype)observerForInfoWithPid:(pid_t)pid; 
Parameters
pid

An integer, the running application's BSD Unix process identification number (PID).

Return Value

An autoreleased PFObserver object, or nil if the target application is not running.

Discussion

Use this convenience method to create an observer that uses a delegate method instead of a callback method and includes an info dictionary to respond to accessibility notifications.

A client application must call -setDelegate: and -registerForNotification:fromElement:contextInfo: in order to receive notifications.

See -initForInfoWithPid: for important information about creating new observer objects.

See also +observerForInfoWithPath: , +observerForInfoWithURL: and +observerForInfoWithBundleIdentifier:.


observerForInfoWithPid:notificationDelegate:infoCallbackSelector:


Convenience class method creates and returns an initialized PFObserver object that uses a callback method that includes an info dictionary with pid, the target application's BSD Unix process identification number (PID), temporary notification delegate callbackDelegate, and callback selector callback. Provides full observer management.

+ (nullable instancetype)observerForInfoWithPid:(pid_t)pid 
        notificationDelegate:(nullable id)callbackDelegate 
        infoCallbackSelector:(nullable SEL)callback; 
Parameters
pid

An integer, the running application's BSD Unix process identification number (PID).

callbackDelegate

An object of any type. A client typically passes self in this parameter.

callback

The notification delegate's Objective-C selector to be invoked when a notification is received.

Return Value

An autoreleased PFObserver object, or nil if the target application is not running.

Discussion

Use this method to create an observer for a specific application given its BSD Unix process identification number (PID) and to set up automatic management of the observer, for an observer that uses a callback method instead of a delegate method and includes an info dictionary to respond to accessibility notifications.

See the designated initializer, -initForInfoWithPid:notificationDelegate:infoCallbackSelector:, for full information about use of this method.

See also +observerForInfoWithPath:notificationDelegate:infoCallbackSelector: , +observerForInfoWithURL:notificationDelegate:infoCallbackSelector: and +observerForInfoWithPid:notificationDelegate:infoCallbackSelector:.


observerForInfoWithURL:


Convenience class method creates and returns an initialized PFObserver object that uses a delegate method and includes an info dictionary with url, the file URL for the target application's bundle or file.

+ (nullable instancetype)observerForInfoWithURL:(nullable NSURL *)url; 
Parameters
url

An NSURL object referencing the application.

Return Value

An autoreleased PFObserver object, or nil if the target application is not running.

Discussion

Use this convenience method to create an observer that uses a delegate method instead of a callback method and includes an info dictionary to respond to accessibility notifications.

A client application must call -setDelegate: and -registerForNotification:fromElement:contextInfo: in order to receive notifications.

See -initForInfoWithPid: for important information about creating new observer objects.

See also +observerForInfoWithPath: , +observerForInfoWithBundleIdentifier: and +observerForInfoWithPid:.


observerForInfoWithURL:notificationDelegate:infoCallbackSelector:


Convenience class method creates and returns an initialized PFObserver object that uses a callback method that includes an info dictionary with url, the file URL for the target application's bundle or file, temporary notification delegate callbackDelegate, and callback selector callback. Provides full observer management.

+ (nullable instancetype)observerForInfoWithURL:(nullable NSURL *)url 
        notificationDelegate:(nullable id)callbackDelegate 
        infoCallbackSelector:(nullable SEL)callback; 
Parameters
url

An NSURL object referencing the application.

callbackDelegate

An object of any type. A client typically passes self in this parameter.

callback

The notification delegate's Objective-C selector to be invoked when a notification is received.

Return Value

An autoreleased PFObserver object, or nil if the target application is not running.

Discussion

Use this method to create an observer for a specific application given its name and to set up automatic management of the observer, for an observer that uses a callback method instead of a delegate method and includes an info dictionary to respond to accessibility notifications.

See the designated initializer, -initForInfoWithPid:notificationDelegate:infoCallbackSelector:, for full information about use of this method.

See also +observerForInfoWithPath:notificationDelegate:infoCallbackSelector: , +observerForInfoWithBundleIdentifier:notificationDelegate:infoCallbackSelector: and +observerForInfoWithPid:notificationDelegate:infoCallbackSelector:.


observersForBundleIdentifier:


Class method returns an array of observers for the running application at url.

+ (NSArray<__kindof PFObserver *> *)
        observersForBundleIdentifier:(NSString *)bundleIdentifier; 
Parameters
bundleIdentifier

An NSString object, the application bundle's identifier.

Return Value

An NSArray object containing PFObserver objects. The array is empty if no observers exist for the application or the application is not running.

Discussion

This method only returns observers that were created using PFObserver factory methods.


observersForPath:


Class method returns an array of observers for the running application at fullPath.

+ (NSArray<__kindof PFObserver *> *)observersForPath:(NSString *)fullPath; 
Parameters
fullPath

An NSString object giving the full path to the application.

Return Value

An NSArray object containing PFObserver objects. The array is empty if no observers exist for the application or the application is not running.

Discussion

This method only returns observers that were created using PFObserver factory methods.


observersForPid:


Class method returns an array of observers for the running application whose BSD Unix application process identification number is pid.

+ (NSArray<__kindof PFObserver *> *)observersForPid:(pid_t)pid; 
Parameters
pid

An integer, a running application's BSD Unix process identification number (PID).

Return Value

An NSArray object containing PFObserver objects. The array is empty if no observers exist for the application or the application is not running.

Discussion

This method only returns observers that were created using PFObserver factory methods.


observersForURL:


Class method returns an array of observers for the running application at url.

+ (NSArray<__kindof PFObserver *> *)observersForURL:(NSURL *)url; 
Parameters
url

An NSURL object referencing the application.

Return Value

An NSArray object containing PFObserver objects. The array is empty if no observers exist for the application or the application is not running.

Discussion

This method only returns observers that were created using PFObserver factory methods.


observerWithBundleIdentifier:


Convenience class method creates and returns an initialized PFObserver object with bundleIdentifier, the target application's bundle identifier.

+ (nullable instancetype)observerWithBundleIdentifier:(nullable NSString *)bundleIdentifier; 
Parameters
bundleIdentifier

An NSString object, the application bundle's identifier.

Return Value

An autoreleased PFObserver object, or nil if the target application is not running.

Discussion

Use this convenience method to create an observer that uses a delegate method instead of a callback method to respond to accessibility notifications.

A client application must call -setDelegate: and -registerForNotification:fromElement:contextInfo: in order to receive notifications.

See -initWithPid: for important information about creating new observer objects.

See also +observerWithPath: , +observerWithURL: and +observerWithPid:.


observerWithBundleIdentifier:notificationDelegate:callbackSelector:


Convenience class method creates and returns an initialized PFObserver object with bundleIdentifier, the target application's bundle identifier, temporary notification delegate callbackDelegate, and callback selector callback. Provides full observer management.

+ (nullable instancetype)observerWithBundleIdentifier:(nullable NSString *)bundleIdentifier 
        notificationDelegate:(nullable id)callbackDelegate 
        callbackSelector:(nullable SEL)callback; 
Parameters
bundleIdentifier

An NSString object, the application bundle's identifier.

callbackDelegate

An object of any type. A client typically passes self in this parameter.

callback

The notification delegate's Objective-C selector to be invoked when a notification is received.

Return Value

An autoreleased PFObserver object, or nil if the target application is not running.

Discussion

Use this method to create an observer for a specific application given its name and to set up automatic management of the observer, for an observer that uses a callback method instead of a delegate method to respond to accessibility notifications.

See the designated initializer, -initWithPid:notificationDelegate:callbackSelector:, for full information about use of this method.

See also +observerWithPath:notificationDelegate:callbackSelector: , +observerWithURL:notificationDelegate:callbackSelector: and +observerWithPid:notificationDelegate:callbackSelector:.


observerWithName:


DEPRECATED. Convenience class method creates and returns an initialized PFObserver object with name, the name of the target application. Provides full observer management.

+ (nullable instancetype)observerWithName:(nullable NSString *)name; 
Parameters
name

An NSString object giving the name of the application file.

Return Value

An autoreleased PFObserver object, or nil if the target application is not running.

Discussion

This method is deprecated. It was used to create an observer for a specific application given its name and to set up automatic management of the observer, for an observer that uses a delegate method instead of a callback method to respond to accessibility notifications. Use +observerWithPath: instead.

A client application must call -setDelegate: and -registerForNotification:fromElement:contextInfo: in order to receive notifications.

See -initWithPid: for important information about creating new observer objects.

See also +observerWithPath: , +observerWithURL: , +observerWithBundleIdentifier: and +observerWithPid:.


observerWithName:notificationDelegate:callbackSelector:


DEPRECATED. Convenience class method creates and returns an initialized PFObserver object with name, the name of the target application, temporary notification delegate callbackDelegate, and callback selector callback. Provides full observer management.

+ (nullable instancetype)observerWithName:(nullable NSString *)name 
        notificationDelegate:(nullable id)callbackDelegate 
        callbackSelector:(nullable SEL)callback; 
Parameters
name

An NSString object giving the name of the application file.

callbackDelegate

An object of any type. A client typically passes self in this parameter.

callback

The notification delegate's Objective-C selector to be invoked when a notification is received.

Return Value

An autoreleased PFObserver object, or nil if the target application is not running.

Discussion

This method is deprecated. It was used to create an observer for a specific application given its name and to set up automatic management of the observer, for an observer that uses a callback method instead of a delegate method to respond to accessibility notifications. Use +observerWithPath:notificationDelegate:callbackSelector: instead.

See the designated initializer, -initWithPid:notificationDelegate:callbackSelector:, for full information about use of this method.

See also +observerWithPath:notificationDelegate:callbackSelector: , +observerWithURL:notificationDelegate:callbackSelector: , +observerWithBundleIdentifier:notificationDelegate:callbackSelector: and +observerWithPid:notificationDelegate:callbackSelector:.


observerWithPath:


Convenience class method creates and returns an initialized PFObserver object with fullPath, the full path to the target application's bundle or file. Provides full observer management.

+ (nullable instancetype)observerWithPath:(nullable NSString *)fullPath; 
Parameters
fullPath

An NSString object giving the full path to the application.

Return Value

An autoreleased PFObserver object, or nil if the target application is not running.

Discussion

Use this convenience method to create an observer that uses a delegate method instead of a callback method to respond to accessibility notifications.

A client application must call -setDelegate: and -registerForNotification:fromElement:contextInfo: in order to receive notifications.

See -initWithPid: for important information about creating new observer objects.

See also +observerWithURL: , +observerWithBundleIdentifier: and +observerWithPid:.


observerWithPath:notificationDelegate:callbackSelector:


Convenience class method creates and returns an initialized PFObserver object with fullPath, the full path to the target application's bundle or file, temporary notification delegate callbackDelegate, and callback selector callback. Provides full observer management.

+ (nullable instancetype)observerWithPath:(nullable NSString *)fullPath 
        notificationDelegate:(nullable id)callbackDelegate 
        callbackSelector:(nullable SEL)callback; 
Parameters
fullPath

An NSString object giving the full path to the application.

callbackDelegate

An object of any type. A client typically passes self in this parameter.

callback

The notification delegate's Objective-C selector to be invoked when a notification is received.

Return Value

An autoreleased PFObserver object, or nil if the target application is not running.

Discussion

Use this method to create an observer for a specific application given its name and to set up automatic management of the observer, for an observer that uses a callback method instead of a delegate method to respond to accessibility notifications.

See the designated initializer, -initWithPid:notificationDelegate:callbackSelector:, for full information about use of this method.

See also +observerWithURL:notificationDelegate:callbackSelector: , +observerinitWithBundleIdentifier:notificationDelegate:callbackSelector: and +observerWithPid:notificationDelegate:callbackSelector:.


observerWithPid:


Convenience class method creates and returns an initialized PFObserver object with pid, the target application's BSD Unix process identification number (PID). Provides full observer management.

+ (nullable instancetype)observerWithPid:(pid_t)pid; 
Parameters
pid

An integer, the running application's BSD Unix process identification number (PID).

Return Value

An autoreleased PFObserver object, or nil if the target application is not running.

Discussion

Use this convenience method to create an observer that uses a delegate method instead of a callback method to respond to accessibility notifications.

A client application must call -setDelegate: and -registerForNotification:fromElement:contextInfo: in order to receive notifications.

See -initWithPid: for important information about creating new observer objects.

See also +observerWithPath: , +observerWithURL: and +observerWithBundleIdentifier:.


observerWithPid:notificationDelegate:callbackSelector:


Convenience class method creates and returns an initialized PFObserver object with pid, the target application's BSD Unix process identification number (PID), temporary notification delegate callbackDelegate, and callback selector callback. Provides full observer management.

+ (nullable instancetype)observerWithPid:(pid_t)pid 
        notificationDelegate:(nullable id)callbackDelegate 
        callbackSelector:(nullable SEL)callback; 
Parameters
pid

An integer, the running application's BSD Unix process identification number (PID).

callbackDelegate

An object of any type. A client typically passes self in this parameter.

callback

The notification delegate's Objective-C selector to be invoked when a notification is received.

Return Value

An autoreleased PFObserver object, or nil if the target application is not running.

Discussion

Use this method to create an observer for a specific application given its BSD Unix process identification number (PID) and to set up automatic management of the observer, for an observer that uses a callback method instead of a delegate method to respond to accessibility notifications.

See the designated initializer, -initWithPid:notificationDelegate:callbackSelector:, for full information about use of this method.

See also +observerWithPath:notificationDelegate:callbackSelector: , +observerWithURL:notificationDelegate:callbackSelector: and +observerWithPid:notificationDelegate:callbackSelector:.


observerWithURL:


Convenience class method creates and returns an initialized PFObserver object with url, the file URL for the target application's bundle or file.

+ (nullable instancetype)observerWithURL:(nullable NSURL *)url; 
Parameters
url

An NSURL object referencing the application.

Return Value

An autoreleased PFObserver object, or nil if the target application is not running.

Discussion

Use this convenience method to create an observer that uses a delegate method instead of a callback method to respond to accessibility notifications.

A client application must call -setDelegate: and -registerForNotification:fromElement:contextInfo: in order to receive notifications.

See -initWithPid: for important information about creating new observer objects.

See also +observerWithPath: , +observerWithBundleIdentifier: and +observerWithPid:.


observerWithURL:notificationDelegate:callbackSelector:


Convenience class method creates and returns an initialized PFObserver object with url, the file URL for the target application's bundle or file, temporary notification delegate callbackDelegate, and callback selector callback. Provides full observer management.

+ (nullable instancetype)observerWithURL:(nullable NSURL *)url 
        notificationDelegate:(nullable id)callbackDelegate 
        callbackSelector:(nullable SEL)callback; 
Parameters
url

An NSURL object referencing the application.

callbackDelegate

An object of any type. A client typically passes self in this parameter.

callback

The notification delegate's Objective-C selector to be invoked when a notification is received.

Return Value

An autoreleased PFObserver object, or nil if the target application is not running.

Discussion

Use this method to create an observer for a specific application given its name and to set up automatic management of the observer, for an observer that uses a callback method instead of a delegate method to respond to accessibility notifications.

See the designated initializer, -initWithPid:notificationDelegate:callbackSelector:, for full information about use of this method.

See also +observerWithPath:notificationDelegate:callbackSelector: , +observerWithBundleIdentifier:notificationDelegate:callbackSelector: and +observerWithPid:notificationDelegate:callbackSelector:.


pidNumber


Returns the BSD Unix process identification number (PID) of the receiver's target application.

- (NSNumber *)pidNumber; 
Return Value

An NSNumber object encoding an integer value.

Discussion

It is sometimes useful to know the process identification number of an application. For example, it can be used with a variety of Carbon functions to access information not otherwise readily available in Cocoa.

Use NSNumber's -intValue method to extract the integer value of the result.


registerForNotification:fromElement:contextInfo:


Registers the receiver to observe element for notification, saving contextInfo for return in the client's callback selector, returning YES if successful.

- (BOOL)registerForNotification:(NSString *)notification 
        fromElement:(nullable PFUIElement *)element contextInfo:(nullable void *)contextInfo; 
Parameters
notification

An NSString representing a notification; you may use a string constant from the NSAccessibility informal protocol or from the accessibility API's AXConstants.h header file cast to NSString*, or the string itself.

element

The PFUIElement object to observe. If element is nil, the root application UI element is observed.

contextInfo

An object, typically of type NSDictionary, containing any information that the receiver's callback method may need at the time the notification is posted. This information is ignored if the client application uses a delegate method instead of a callback method.

Return Value

YES if the receiver was successfully registered; NO, if not.

Discussion

Use this method to register to observe a specific UI element in a target application in order to receive notifications that it posts. Optionally pass nil as the element argument to register to observe the root application element in order to receive notifications posted by all elements in the application. It is often more convenient to observe the root application element, because this ensures that you will receive all of the target application's notifications when any of its elements changes state.

For clients that use a delegate method, the delegate method receives the bundle identifier and full path of the target application file, the notification, the observed element, and the affected element (which may differ from the observed element). For clients that use a callback method, the callback method receives the observer, the notification, the affected element (which may differ from the observed element), and contextInfo in its parameters.

Any one observer is associated with a single client delegate method or callback method no matter how many elements it is registered to observe or how many accessibility notifications it is registered to receive. A delegate method or callback method distinguishes how to respond to different notifications affecting different elements by testing its parameters. See -initWithPid:notificationDelegate:callbackSelector: for the required callback method signature for clients that use a callback method instead of a delegate method.

If the client needs to remember that element is the observed element, it may have to cache element at registration time. This is because the callback method will not necessarily return element as the affected element in every case. This is so when element is the root application element, because when the root application is observed, the affected element may be some other element.

The client's delegate method or callback method will always receive the affected element, even when observing NSAccessibilityUIElementDestroyedNotification. However, you must treat a destroyed element as invalid; do not pass it as a parameter to methods that call accessibility API functions. You can, however, use a destroyed element with PFUIElement's -pid, and with PFUIElement's -isEqual: and -isEqualToElement: to manage any element cache you maintain. Note that attempting to pass a destroyed UI element in an accessibility API function is not guaranteed to return an accessibility API error. PFUIElement's -elementInfo method will return some valid information about a destroyed element.

Many UI elements do not support every notification known to the accessibility API. If you attempt to register an element for a notification that it does not support, this method returns NO. Use the receiving observer's -isRegisteredForNotification:fromElement: at any time to test whether a particular element is registered for a particular notification; it will always return NO for an element that does not support the specified notification.

In Mac OS X 10.5 (Leopard), registering for either the AXApplicationActivated or AXApplicationDeactivated notification also registers for the other. The same is true of the AXApplicationHidden and AXApplicationShown notifications. The framework does this in order to work around a longstanding Accessibility API bug that Apple fixed in Mac OS X 10.6 (Snow Leopard).

It is the client's responsibility to unregister an observer for all notifications before releasing it. This can be done by sending -unregisterForAllNotifications. For convenience, -removeObserversForPid: unregisters all observers for all notifications and releases all observers at once.

See also -unregisterForNotification:fromElement:, -unregisterForAllNotificationsFromElement:, -unregisterForAllNotifications and -isRegisteredForNotification:fromElement:.


registrations


Returns a mutable array containing all registrations currently in effect in the receiver; that is, all registrations that the client has registered and has not unregistered using this observer.

- (NSMutableArray *)registrations; 
Return Value

An NSMutableArray object containing all registrations currently in effect in the receiving observer.

Discussion

Each registration in the array is an NSDctionary object containing the registered notification string with key "registrationNotificationKey" and the registered PFUIElement object with key "registrationElementKey".


removeObserversForBundleIdentifier:


Class method unregisters and removes all observers for the running application at url, deallocating them if they have not been retained by the client.

+ (void)removeObserversForBundleIdentifier:(NSString *)bundleIdentifier; 
Parameters
bundleIdentifier

An NSString object, the application bundle's identifier.

Discussion

This method only unregisters and removes observers that were created using PFObserver factory methods.

See -registerForNotification:fromElement:contextInfo: for information regarding registration and unregistration.


removeObserversForPath:


Class method unregisters and removes all observers for the running application at fullPath, deallocating them if they have not been retained by the client.

+ (void)removeObserversForPath:(NSString *)fullPath; 
Parameters
fullPath

An NSString object giving the full path to the application.

Discussion

This method only unregisters and removes observers that were created using PFObserver factory methods.

See -registerForNotification:fromElement:contextInfo: for information regarding registration and unregistration.


removeObserversForPid:


Class method unregisters and removes all observers for the running application whose BSD Unix application process identification number is pid, deallocating them if they have not been retained by the client.

+ (void)removeObserversForPid:(pid_t)pid; 
Parameters
pid

An integer, a running application's BSD Unix process identification number (PID).

Discussion

This method only unregisters and removes observers that were created using PFObserver factory methods.

See -registerForNotification:fromElement:contextInfo: for information regarding registration and unregistration.


removeObserversForURL:


Class method unregisters and removes all observers for the running application at url, deallocating them if they have not been retained by the client.

+ (void)removeObserversForURL:(NSURL *)url; 
Parameters
url

An NSURL object referencing the application.

Discussion

This method only unregisters and removes observers that were created using PFObserver factory methods.

See -registerForNotification:fromElement:contextInfo: for information regarding registration and unregistration.


setDelegate:


Sets the receiver's delegate to object.

- (void)setDelegate:(nullable id <PFObserverDelegate>)object; 
Parameters
object

An object of any type, or nil to remove an existing delegate.

Discussion

The delegate must adopt the PFObserverDelegate formal protocol to receive delegate messages.

The PFObserver delegate methods, which are optional, are declared in the PFObserverDelegate protocol. If one of them is implemented by the delegate, it is automatically called when the receiving observer detects a change in a UI element which it has registered to observe. The delegate must adopt the PFObserverDelegate formal protocol to receive delegate messages.

The only available delegate messages are -applicationWithIdentifier:atPath:didPostAccessibilityNotification:fromObservedUIElement:forAffectedUIElement: and -applicationWithIdentifier:atPath:didPostAccessibilityNotification:fromObservedUIElement:forAffectedUIElement:withInfo:, both of which are optional.

The delegate is not retained. To remove a delegate, pass nil. The delegate is automatically set to nil in -invalidate in case the client neglects to set it to nil.

See also -delegate.


unregisterForAllNotifications


Unregisters the receiver to observe all elements for all notifications.

- (void)unregisterForAllNotifications; 
Discussion

It is the client's responsibility to unregister the receiving observer for all notifications before releasing it. For convenience, -removeObserversForPid: unregisters all observers for all notifications and releases all observers at once.

See also -registerForNotification:fromElement:contextInfo:, -unregisterForNotification:fromElement:, -unregisterForAllNotificationsFromElement: and -isRegisteredForNotification:fromElement:.


unregisterForAllNotificationsFromElement:


Unregisters the receiver to observe element for all notifications.

Parameters
element

The PFUIElement object being observed. If element is nil, the notifications are unregistered from the root application UI element.

Discussion

It is the client's responsibility to unregister the receiving observer for all notifications before releasing it. For convenience, -removeObserversForPid: unregisters all observers for all notifications and releases all observers at once.

See also -registerForNotification:fromElement:contextInfo:, -unregisterForNotification:fromElement:, -unregisterForAllNotifications and -isRegisteredForNotification:fromElement:.


unregisterForNotification:fromElement:


Unregisters the receiver to observe element for notification.

- (void)unregisterForNotification:(NSString *)notification 
        fromElement:(nullable PFUIElement *)element; 
Parameters
notification

An NSString representing a notification; you may use a string constant from the NSAccessibility informal protocol or from the accessibility API's AXConstants.h header file cast to NSString*, or the string itself.

element

The PFUIElement object being observed. If element is nil, the notification is unregistered from the root application UI element.

Discussion

It is the client's responsibility to unregister the receiving observer for all notifications before releasing it. For convenience, -removeObserversForPid: unregisters all observers for all notifications and releases all observers at once.

See also -registerForNotification:fromElement:contextInfo:, -unregisterForAllNotificationsFromElement:, -unregisterForAllNotifications and -isRegisteredForNotification:fromElement:.