I have a class that manages messages coming from and going to an external accessory to an iPad. In the 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];
...
}
in 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 the external accessory to the iPad the accessoryDidConnect: fires followed by an accessoryDidDisconnect: followed by accessoryDidConnect:
I can't figure out why I would get an extra connect and disconnect. Any ideas?