kejoki
kejoki

Reputation: 103

Bluetooth stopping main thread

I have an iOS 8 application that I'm using to transfer data via bluetooth from 1 device to another.

I have all of the services and characteristics working and can do the actual transfer.

I've tried to push the central manager onto another thread, but the UI on the central side locks up until the transfer is completed. When I look in instruments, I see thread 1 just get nailed.

I've tried this, but is hasn't seemed to work...

[[CBCentralManager alloc] initWithDelegate:self queue:dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0)];

What is the correct way to toss the CBManager into the background, so that it is not gumming up the UI thread?

Upvotes: 0

Views: 1121

Answers (1)

Paulw11
Paulw11

Reputation: 115075

Specifying a queue when you initialise CBCentralManager will deliver CBCentralManager delegate events on that queue, but your data transfer is performed by CBPeripheral methods. You should explicitly dispatch your calls to writeValue on the background thread

Upvotes: 1

Related Questions