macos – 列出Swift中蓝牙设备范围内的设备
发布时间:2020-12-14 05:30:04 所属栏目:百科 来源:网络整理
导读:我在 Xcode 6游乐场中有以下代码: import Cocoaimport IOBluetoothclass BlueDelegate : IOBluetoothDeviceInquiryDelegate { func deviceInquiryComplete(sender: IOBluetoothDeviceInquiry,error: IOReturn,aborted: Bool) { aborted var devices = sende
我在
Xcode 6游乐场中有以下代码:
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() 我刚刚开始使用OSX下的蓝牙,而我目前想要的只是范围内的设备列表. 它似乎根本没有调用我的委托方法. 我是OSX开发和Swift的新手,所以请保持温和. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |