I have the following code in a Xcode 6 playground:
import Cocoa
import IOBluetooth
class BlueDelegate : IOBluetoothDeviceInquiryDelegate {
func deviceInquiryComplete(sender: IOBluetoothDeviceInquiry, error: IOReturn, aborted: Bool) {
aborted
var devices = sender.foundDevices()
for device : AnyObject in devices {
if let thingy = device as? IOBluetoothDevice {
thingy.getAddress()
}
}
}
}
var inquiry = IOBluetoothDeviceInquiry(delegate: BlueDelegate())
inquiry.start()
I'm just getting started with Bluetooth under OSX, and all I currently would like is a list of devices in range.
It doesn't seem to be calling my delegate method at all.
I'm new to OSX development and Swift, so be gentle. :)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…