I know this is a stupid question but here goes.
I have an older app that uses isConnected. Now I get a warning that it is deprecated. Can I just delete this line of code without any ramification or how do I handle this. Sorry for being so dense.
here is some code it is from the CBPeripheral framework.
- (void)peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error
{
// Deal with errors (if any)
if (error) {
NSLog(@"Error discovering characteristics: %@", [error localizedDescription]);
[self cleanup];
return;
}
}
- (void)cleanup
{
// Don't do anything if we're not connected
if (!self.discoveredPeripheral.isConnected) // here is where the warning comes {
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(readonly) CBPeripheralState state; in my .h
I don't get an error Can anyone verify this for me?
As Apple Documentation says:
isConnected
A Boolean value indicating whether the peripheral is currently connected to the central manager. (read-only) (Deprecated in iOS 7.0. Use the state property instead.)
Just replace your code by:
if (self.discoveredPeripheral.state != CBPeripheralStateConnected)
return;
On the other hand, if that's all you have in this method, basically you are doing nothing. So you could just remove that dead code. Which makes me thinks something missing... No cleanup?
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments