Я использую следующий код, чтобы знать, когда устройство подключено:Как узнать, какое устройство было подключено?
- (void)applicationDidBecomeActive:(UIApplication *)application
{
//code...
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(accesoryChanged:) name:EAAccessoryDidConnectNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(accesoryChanged:) name:EAAccessoryDidDisconnectNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(accesoryChanged:) name:UIScreenDidConnectNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(accesoryChanged:) name:UIScreenDidDisconnectNotification object:nil];
EAAccessoryManager *accessoryManager = [EAAccessoryManager sharedAccessoryManager];
[accessoryManager registerForLocalNotifications];
}
- (void)accesoryChanged:(NSNotification*)note;
{
if(note.name == EAAccessoryDidConnectNotification)
{
EAAccessory* accessory = [note.userInfo objectForKey:EAAccessoryKey];
//code...
}
else if(note.name == EAAccessoryDidDisconnectNotification)
{
EAAccessory* accessory = [note.userInfo objectForKey:EAAccessoryKey];
//code...
}
}
И:
accessory.name
я могу получить имя устройства, но я не мог найти способ узнать, какое устройство (например, контроллер или адаптер HDMI).
Есть ли способ получить эту информацию?
Заранее спасибо.