'isConnected' deprecated in iOS 7

user1114881

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?

Vincent Guerci

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

iOS 7 : 'isa' is deprecated

From Dev

IOS 7 sizeWithFont Deprecated

From Dev

ios 7 initWithOverlay deprecated

From Dev

IOS 7 sizeWithFont Deprecated

From Java

Replacement for deprecated sizeWithFont: in iOS 7?

From Dev

Deprecated in iOS7: AudioSessionSetProperty

From Dev

Alternative to deprecated AudioSessionGetProperty, for iOS 7

From Dev

iOS 7 - UIPopoverController : deprecated arrows?

From Dev

MKPolylineView initWithPolyLine: is deprecated in iOS 7

From Java

Replacement for deprecated -sizeWithFont:constrainedToSize:lineBreakMode: in iOS 7?

From Dev

reportAchievementWithCompletionHandler deprecated in iOS7 but replacement not specified

From Dev

UITabBarItem setFinishedSelectedImage: deprecated in iOS7

From Dev

Swift - Coordinate is unavailable: APIs deprecated as of iOS 7

From Dev

iOS 7 - region.center deprecated

From Dev

sizeWithFont:constrainedToSize:lineBreakMode: deprecated in iOS7

From Dev

GKPeerPickerController has been deprecated in iOS 7

From Dev

sizeWithFont: ConstrainedToSize: lineBreakMode: method is deprecated in iOS 7

From Dev

iOS7: method drawMapRect is deprecated

From Dev

Performance issue in iOS 7 due to deprecated methods

From Dev

Performance issue in iOS 7 due to deprecated methods

From Dev

Lost with the replacement for deprecated sizeWithFont: in iOS 7

From Dev

What to use instead of regionMonitoringAvailable which is deprecated in iOS 7?

From Dev

What should I use instead of deprecated GKLeaderboardViewController in iOS7?

From Dev

GameKit GKMatchMaker inviteHandler deprecated in iOS7, what is the replacement?

From Dev

iOS 7 iAd cocos2d deprecated

From Dev

SegmentedControlStyle deprecated in iOS 7 and later (8.4) | Xcode 6.4

From Dev

What to use instead of regionMonitoringAvailable which is deprecated in iOS 7?

From Dev

'init(contentsOfURL:)' is unavailable: APIs deprecated as of iOS 7 and earlier are unavailable in Swift

From Dev

sendAsynchronousRequest deprecated in iOS 9

Related Related

  1. 1

    iOS 7 : 'isa' is deprecated

  2. 2

    IOS 7 sizeWithFont Deprecated

  3. 3

    ios 7 initWithOverlay deprecated

  4. 4

    IOS 7 sizeWithFont Deprecated

  5. 5

    Replacement for deprecated sizeWithFont: in iOS 7?

  6. 6

    Deprecated in iOS7: AudioSessionSetProperty

  7. 7

    Alternative to deprecated AudioSessionGetProperty, for iOS 7

  8. 8

    iOS 7 - UIPopoverController : deprecated arrows?

  9. 9

    MKPolylineView initWithPolyLine: is deprecated in iOS 7

  10. 10

    Replacement for deprecated -sizeWithFont:constrainedToSize:lineBreakMode: in iOS 7?

  11. 11

    reportAchievementWithCompletionHandler deprecated in iOS7 but replacement not specified

  12. 12

    UITabBarItem setFinishedSelectedImage: deprecated in iOS7

  13. 13

    Swift - Coordinate is unavailable: APIs deprecated as of iOS 7

  14. 14

    iOS 7 - region.center deprecated

  15. 15

    sizeWithFont:constrainedToSize:lineBreakMode: deprecated in iOS7

  16. 16

    GKPeerPickerController has been deprecated in iOS 7

  17. 17

    sizeWithFont: ConstrainedToSize: lineBreakMode: method is deprecated in iOS 7

  18. 18

    iOS7: method drawMapRect is deprecated

  19. 19

    Performance issue in iOS 7 due to deprecated methods

  20. 20

    Performance issue in iOS 7 due to deprecated methods

  21. 21

    Lost with the replacement for deprecated sizeWithFont: in iOS 7

  22. 22

    What to use instead of regionMonitoringAvailable which is deprecated in iOS 7?

  23. 23

    What should I use instead of deprecated GKLeaderboardViewController in iOS7?

  24. 24

    GameKit GKMatchMaker inviteHandler deprecated in iOS7, what is the replacement?

  25. 25

    iOS 7 iAd cocos2d deprecated

  26. 26

    SegmentedControlStyle deprecated in iOS 7 and later (8.4) | Xcode 6.4

  27. 27

    What to use instead of regionMonitoringAvailable which is deprecated in iOS 7?

  28. 28

    'init(contentsOfURL:)' is unavailable: APIs deprecated as of iOS 7 and earlier are unavailable in Swift

  29. 29

    sendAsynchronousRequest deprecated in iOS 9

HotTag

Archive