1

我的问题是,在我启动 IOBluetoothDeviceInquiry 的第 35 行,它给了我以下错误:Failed to create connection to the daemon: Distributed objects message send timed out这是我的代码不起作用:

import Cocoa
import IOBluetooth

class BlueDelegate : IOBluetoothDeviceInquiryDelegate {
    func deviceInquiryDeviceFound(_ sender: IOBluetoothDeviceInquiry, device: IOBluetoothDevice) {
        sender.stop()
        let thingy = device
        print("Found Device: \(thingy.nameOrAddress)")
        print(IOBluetoothDevicePair(device: thingy).start())
    }
}


@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {

    let bt = IOBluetoothDeviceInquiry(delegate: BlueDelegate())

    func applicationDidFinishLaunching(_ aNotification: Notification) {
        // Insert code here to initialize your application
        print("Starting...")
        bt?.updateNewDeviceNames = true
        print("0")
        bt?.stop()
        print("1")
        switch (bt?.start())! {
            case kIOReturnSuccess: print("Success!");break
            case kIOReturnError: print("General Error.");break
            case kIOReturnNoMemory: print("Memory Allocation Error.");break
            case kIOReturnNoResources: print("resource shortage");break
            case kIOReturnIPCError: print("Mach IPC failure");break
            case kIOReturnNoDevice: print("no such device");break

            default:print("Unknown Status.");break
        }
        print("2")
    }

    func applicationWillTerminate(_ aNotification: Notification) {
        // Insert code here to tear down your application
        bt?.stop()
    }


}

我应该怎么做才能解决这个问题,以便我的应用程序可以继续开发?

提前致谢,

亚伦詹姆。

4

0 回答 0