EAAccessoryManager Class Reference
| Inherits from | |
| Conforms to | |
| Availability | Available in iOS 3.0 and later. |
| Declared in | EAAccessoryManager.h |
Overview
The EAAccessoryManager class coordinates the attached accessories for an iOS-based device. You use this class to retrieve a list of accessories to which your application might want to connect. You also use this class to start and stop the sending of accessory-related connect and disconnect notifications.
Tasks
Getting the Shared Accessory Manager
Starting and Stopping Accessory Notifications
Presenting the Bluetooth Picker
Getting the Available Accessories
-
connectedAccessoriesproperty
Properties
connectedAccessories
The accessory objects corresponding to the list of currently connected accessories. (read-only)
Discussion
This property contains an array of EAAccessory objects. Each object corresponds to an accessory that is connected and available for your application to use. Because the contents of this property can change dynamically based on the connection and disconnection of accessories, you should not cache the value of this property.
Availability
- Available in iOS 3.0 and later.
Declared In
EAAccessoryManager.hClass Methods
sharedAccessoryManager
Returns the shared EAAccessoryManager object for the iOS-based device.
Return Value
The shared accessory manager object.
Discussion
You should always use this method to obtain the accessory manager object and should not try to create instances directly.
Availability
- Available in iOS 3.0 and later.
Declared In
EAAccessoryManager.hInstance Methods
registerForLocalNotifications
Begins the delivery of accessory-related notifications to the current application.
Discussion
You must call this method if you want to be notified when accessories become connected or disconnected. The system does not send these notifications automatically, so calling this method lets the system know that your application is interested in them. Typically, you would call this method only once early in your application, either before or after configuring your notification observers. When you no longer need to monitor these notifications, you should call the matching unregisterForLocalNotifications method.
You can configure your notification observers either before or after calling this method. Because the shared accessory manager is the only object that sends accessory-related notifications, specifying that object or nil for the notification sender has the same outcome.
Availability
- Available in iOS 3.0 and later.
See Also
-
– unregisterForLocalNotifications -
addObserver:selector:name:object:(NSNotificationCenter)
Declared In
EAAccessoryManager.hshowBluetoothAccessoryPickerWithNameFilter:completion:
Displays an alert that allows the user to pair the device with a Bluetooth accessory.
Parameters
- predicate
The predicate is evaluated using the name of the Bluetooth accessory. Only devices whose names match the predicate are displayed by the picker. If you specify
nil, this method displays all discovered accessories.- completion
A completion block to execute when the picker is dismissed. You can use this block to track any errors that might have occurred during the pairing process.
Discussion
This method synchronously displays an alert containing the list of Bluetooth accessories that have been discovered by the current device and that match the specified filter (if any). The user can select an accessory from this list and pair the device to it. Pairing an accessory updates the accessory manager’s list of connected accessories and generates a corresponding connection notification.
Availability
- Available in iOS 6.0 and later.
Declared In
EAAccessoryManager.hunregisterForLocalNotifications
Stops the delivery of accessory-related notifications to the current application.
Discussion
Typically, you would call this method either when your application exits or when you no longer want to receive accessory-related notifications. Calls to this method must be balanced with a preceding call to the registerForLocalNotifications method.
Availability
- Available in iOS 3.0 and later.
Declared In
EAAccessoryManager.hConstants
Notification User Info Keys
Keys associated with the info dictionary of accessory notifications.
NSString *const EAAccessoryKey; NSString *const EAAccessorySelectedKey;
Constants
EAAccessoryKeyThe value assigned to this key is the
EAAccessoryobject whose status changed.Available in iOS 3.0 and later.
Declared in
EAAccessoryManager.h.EAAccessorySelectedKeyThe value assigned to this key is the
EAAccessoryobject that was selected by the user. This key is included in the info dictionary when the user pairs a Bluetooth accessory with the device using the Bluetooth picker.Available in iOS 6.0 and later.
Declared in
EAAccessoryManager.h.
EABluetoothAccessoryPickerCompletion
The completion block for the Bluetooth picker.
typedef void(^EABluetoothAccessoryPickerCompletion)(NSError *error);
Discussion
You use this block to process results generated by the showBluetoothAccessoryPickerWithNameFilter:completion: method. The block receives an NSError object as its only parameter. If no error occurred, this parameter is set to nil.
Availability
- Available in iOS 6.0 and later.
Declared In
EAAccessoryManager.hAccessory Picker Error Domain
Constants associated with the Bluetooth picker.
NSString *const EABluetoothAccessoryPickerErrorDomain;
Constants
EABluetoothAccessoryPickerErrorDomainThe domain for errors passed to a
EABluetoothAccessoryPickerCompletionblock.Available in iOS 6.0 and later.
Declared in
EAAccessoryManager.h.
EABluetoothAccessoryPickerErrorCode
The error codes that may be passed in an error object to a EABluetoothAccessoryPickerCompletion block.
enum {
EABluetoothAccessoryPickerAlreadyConnected,
EABluetoothAccessoryPickerResultNotFound,
EABluetoothAccessoryPickerResultCancelled,
EABluetoothAccessoryPickerResultFailed
};
typedef NSInteger EABluetoothAccessoryPickerErrorCode;
Constants
EABluetoothAccessoryPickerAlreadyConnectedThe specified accessory was already connected.
Available in iOS 6.0 and later.
Declared in
EAAccessoryManager.h.EABluetoothAccessoryPickerResultNotFoundThe specified accessory could not be found, perhaps because it was turned off prior to connection.
Available in iOS 6.0 and later.
Declared in
EAAccessoryManager.h.EABluetoothAccessoryPickerResultCancelledThe user canceled the picker alert.
Available in iOS 6.0 and later.
Declared in
EAAccessoryManager.h.EABluetoothAccessoryPickerResultFailedSelecting an accessory failed for an unknown reason.
Available in iOS 6.0 and later.
Declared in
EAAccessoryManager.h.
Notifications
EAAccessoryDidConnectNotification
The notification object is the shared accessory manager. The userInfo dictionary contains an EAAccessorySelectedKey, whose value is an EAAccessory object representing the accessory that is now connected. If a Bluetooth accessory was selected by the user in the Bluetooth picker, this dictionary contains the EAAccessorySelectedKey key. Before delivery of this notification can occur, you must call the registerForLocalNotifications method to let the system know you are interested in receiving this notification.
Availability
- Available in iOS 3.0 and later.
Declared In
EAAccessoryManager.hEAAccessoryDidDisconnectNotification
The notification object is the shared accessory manager. The userInfo dictionary contains an EAAccessorySelectedKey, whose value is the EAAccessory object representing the accessory that was disconnected. Before delivery of this notification can occur, you must call the registerForLocalNotifications method to let the system know you are interested in receiving this notification.
If your accessory manager has a delegate, the delegate can use the accessoryDidDisconnect: method to receive this notification instead.
Availability
- Available in iOS 3.0 and later.
Declared In
EAAccessoryManager.h© 2012 Apple Inc. All Rights Reserved. (Last updated: 2012-09-19)