In iOS 8.3+, Attempting to cast members of accessories parameter from didFindUnconfiguredAccessories method as EAWiFiUnconfiguredAccessory fails

Originator:erik.krietsch
Number:rdar://20691321 Date Originated:4/24/2015
Status:Closed Resolved:
Product:iOS Product Version:iOS 8.3 (12F70)
Classification:Other Bug Reproducible:Always
 
Summary:
In the EAWiFiUnconfiguredAccessoryBrowserDelegate protocol, the method didFindUnconfiguredAccessories provides an accessories parameter of type Set<NSObject>. Attempting to cast members of this set as type EAWiFiUnconfiguredAccessory can result in an app crash, and ultimately prevents 3rd party app from being able to configure via WAC.

Steps to Reproduce:
Create a Single View iOS app using Swift
Add a class that implements the EAWiFiUnconfiguredAccessoryBrowserDelegate
Implement a function to handle the delegate callback - func accessoryBrowser(browser: EAWiFiUnconfiguredAccessoryBrowser!, didFindUnconfiguredAccessories accessories: Set<NSObject>!)

Using the following code inside the above function: 
for object in accessories {
  if let accessory = object as? EAWiFiUnconfiguredAccessory {
    println("success")
  } else {
    println("\(object)")
  }
}
Will result in the console logging a description of the object, describing its class as EAWiFiUnconfiguredAccessory.

Using the following code:
for object in accessories {
  let accessory = object as! EAWiFiUnconfiguredAccessory
}
Will crash the application, and will log the following message:
"Could not cast value of type 'EAWiFiUnconfiguredAccessory' (0x1009ee430) to 'EAWiFiUnconfiguredAccessory' (0x19539a6c8)."

Furthermore the following line:
object is EAWiFiUnconfiguredAccessory
Returns false.


Expected Results:
The members of the accessories collection should be allowed to be cast as an EAWiFiUnconfiguredAccessory class.

Actual Results:
The members of the accessories collection are not recognized as instances of EAWiFiUnconfiguredAccessory.


Version:
8.3 (12F70)

Notes:


Configuration:
iPhone 6 64GB Verizon, using WiFi

Attachments:

Comments

Duplicate of 15796605 (Open)

By erik.krietsch at March 22, 2016, 1:53 p.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!