I know this is a stupid question, but here.
I have an older application that uses isConnected. Now I get a warning that it is out of date. Can I just delete this line of code without any branching or how to do it. Sorry for being so tight.
here is some code from CBPeripheral framework.
- (void)peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error
{
if (error) {
NSLog(@"Error discovering characteristics: %@", [error localizedDescription]);
[self cleanup];
return;
}
}
- (void)cleanup
{
if (!self.discoveredPeripheral.isConnected)
return;
}
I think I found the answer should be
- (void)cleanup
{
// Don't do anything if we're not connected
if (CBPeripheralStateDisconnected) {
return;
}
I also added @property (read-only) state to CBPeripheralState; in my .h
I'm not wrong. Can anyone confirm this for me?
source
share