I have a class that controls messages from an external accessory to an iPad. In init, I have the following code:
- (id) init { self = [super init]; if (!self) return; [[EAAccessoryManager sharedAccessoryManager] registerForLocalNotifications]; //we want to hear about accessories connecting and disconnecting [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(accessoryDidConnect:) name:EAAccessoryDidConnectNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(accessoryDidDisconnect:) name:EAAccessoryDidDisconnectNotification object:nil]; ... }
at dealloc I have
- (void) dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self name:EAAccessoryDidDisconnectNotification object:nil]; [[NSNotificationCenter defaultCenter] removeObserver:self name:EAAccessoryDidConnectNotification object:nil]; [[EAAccessoryManager sharedAccessoryManager] unregisterForLocalNotifications]; }
For some reason, when I connect an external accessory to my iPad, the DidConnect accessory: fires and then the optional DidDisconnect device is added: it follows the DidConnect accessory:
I canβt understand why I get an additional connection and disconnect. Any ideas?
Sam
source share