d.felber d.felber - 3 days ago 5
Swift Question

Why is the "Add Accessory" View Controller presented after long delay?

I have the problem that the

Add Accessory View Controller
(Figure 2) is presented about 6 seconds after I pressed
Add Anyway
in the
Add HomeKit Accessory Alert
(Figure 1) which is waaay to long. (Xcode 8.2 beta, Deployment Target: 10.0, Device iOS: 10.1.1)

The code is fairly simple:

home
is a
HMHome


accessory
is a
HMAccessory


override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
defer {
tableView.deselectRow(at: indexPath, animated: true)
}

let accessory = accessories[indexPath.item]

home.addAccessory(accessory) { error in
// ...
}
}


I already tried wrapping the code in
DispatchQueue.main.async { /**/ }
but that does not fasten the presentation up.




Is this just an issue because the Accessory is not (yet) certified or did I forget to configure / wait for something before I can call
addAccessory
safely?


Note: I have the same issue when adding the Accessory in the HomeKit example provided by Apple




Figure 1: Add HomeKit Accessory Alert


Add HomeKit Accessory Alert

Figure 2: Add Accessory View Controller


Add Accessory View Controller

Answer

The problem disappeared when I updated the firmware of the Bridge.

Comments