خرید بک لینک

Vote count: 0

Is there a way to create an alert right when a BLE device coects/discoects via swift? I have the following code:

func isCoectedToPC(block:(isCoected: Bool) -> Void) -> Void {
    // Sends a Ping request to the PC. The PC has 2 seconds to respond witha Pong, otherwise we will consider us not coected to the PC.
    sendCommandToPC("Ping")
    pingPongCallback = block
    pingPongTimeoutTimer = NSTimer.scheduledTimerWithTimeInterval(2.0, target: NSBlockOperation(block: pingPongTimedOut), selector: #selector(NSOperation.main), userInfo: nil, repeats: false)
}

But with this I will have create a timer to call this function every 5 seconds or so to determine if I am coected or not. I was just wondering if there was a better way to accomplish this.

asked 7 secs ago

- - , .
.

برچسب: نویسنده: استخدام کار تاريخ: سه شنبه 22 تير 1395 ساعت: 4:35

صفحه بندی