Skip to content

Instantly share code, notes, and snippets.

@jonallured
Created June 19, 2015 13:44
Show Gist options
  • Save jonallured/7db6ee6844ac8b56378b to your computer and use it in GitHub Desktop.
Save jonallured/7db6ee6844ac8b56378b to your computer and use it in GitHub Desktop.
In-App WAC with Swift and unsafeBitCast
import UIKit
import ExternalAccessory
class ViewController: UIViewController, EAWiFiUnconfiguredAccessoryBrowserDelegate {
var accessoryBrowser: EAWiFiUnconfiguredAccessoryBrowser?
override func viewDidLoad() {
super.viewDidLoad()
accessoryBrowser = EAWiFiUnconfiguredAccessoryBrowser.init(delegate: self, queue: nil)
accessoryBrowser?.startSearchingForUnconfiguredAccessoriesMatchingPredicate(nil)
}
func accessoryBrowser(browser: EAWiFiUnconfiguredAccessoryBrowser!, didFindUnconfiguredAccessories accessories: Set<NSObject>!) {
for object in accessories {
let accessory = unsafeBitCast(object, EAWiFiUnconfiguredAccessory.self)
println(accessory.name)
}
}
func accessoryBrowser(browser: EAWiFiUnconfiguredAccessoryBrowser!, didUpdateState state: EAWiFiUnconfiguredAccessoryBrowserState) {}
func accessoryBrowser(browser: EAWiFiUnconfiguredAccessoryBrowser!, didRemoveUnconfiguredAccessories accessories: Set<NSObject>!) {}
func accessoryBrowser(browser: EAWiFiUnconfiguredAccessoryBrowser!, didFinishConfiguringAccessory accessory: EAWiFiUnconfiguredAccessory!, withStatus status: EAWiFiUnconfiguredAccessoryConfigurationStatus) {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment