Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS - Property 'isConnected' not found on object of type 'CBPeripheral'

Tags:

ios

iphone

I am trying to replicate an Android App I already made to iOS. I'm trying to make a BLE application where my iOS Device would be able to see and connect to BLE Devices and get the RSSI (I really don't care about the message and other data). Upon a search research, I found this BLTE Central Peripheral Transfer Examplein the iOS Developer Library. Upon downloading, opening the XCode Project, and then ran it. However, I ran into an error shorty after with this code:

if (!self.discoveredPeripheral.isConnected) {
    return;
}

where the error is: Property 'isConnected' not found on object of type 'CBPeripheral'

Upon searching again, I found this link. However, it seems that the thread does not have any solutions as the answers discussed also seem to be deprecated. I can't seem to find any solutions for this issue as well.

Has anyone tried to make the code from the iOS developer library work?

like image 584
Razgriz Avatar asked May 09 '16 07:05

Razgriz


2 Answers

The documentation says

Deprecation Statement
Use the state property instead.

like image 76
vadian Avatar answered Oct 09 '22 21:10

vadian


isConnected has been deprecated, try this code instead

if (self.discoveredPeripheral.state != CBPeripheralStateConnected) {
    return;
}
like image 28
ddb Avatar answered Oct 09 '22 19:10

ddb