7

I am modifying an app that discovers a device via Bluetooth BLE in order to plot the values into a graph. It all works fine (thanks to the help of one of you in the past week). The app was initially written by my husband a while ago and during the discovery of the device, he was using checking code like :

NSLog(@" Failed to Connect to Peripheral : %@   with UUID: %@   ", peripheral, peripheral.UUID);

or

NSLog(@" Connected to Peripheral : %@   with UUID: %@   ", peripheral, peripheral.UUID);

In front of each of these lines (and some more) I get the warning messages that UUID is deprecated: first deprecated in ios 7.0 Since quite a while, I try to find out by what it has been replaced, but on Google, it doesn't look like other people have the same problem and when I go to the Apple Documentation : here

there is no mention of it being deprecated.

I don't understand...

Could somebody please help ? Thanks

EDIT: ADDING SOME INFO

This is what I get on my computer on the console

enter image description here

Clararhea
  • 159
  • 1
  • 2
  • 13
  • It looks like you have pulled up the wrong `UUID` property. The `UUID` property of `CBPeripheral` is deprecated as of 7.0. https://developer.apple.com/library/ios/documentation/CoreBluetooth/Reference/CBPeripheral_Class/index.html#//apple_ref/occ/instp/CBPeripheral/UUID – Ian MacDonald Oct 09 '14 at 13:52
  • Ian, HI. Ok, so what do I replace it with ? I added a picture to show you what I get in the console – Clararhea Oct 09 '14 at 13:56
  • I'm sorry; I can't help you any more than that. (Which is why I posted a comment instead of providing an answer.) The only CoreBluetooth interactions I've had involve iBeacons, not generic Bluetooth devices. – Ian MacDonald Oct 09 '14 at 13:59
  • The CBPeripheral documentation indicates that it is deprecated https://developer.apple.com/library/IOs/documentation/CoreBluetooth/Reference/CBPeripheral_Class/index.html but doesn't provide an alternative. At this point there is nothing you can do but continue to use the deprecated properties. It may be a documentation error. – Paulw11 Oct 09 '14 at 19:31

3 Answers3

17

Update

I have double checked and the UUID property on CBPeer is also deprecated.

From the docs in Xcode I found -

Deprecation Statement
Use the identifier property instead.

And if you use peripheral.identifier.UUIDString you don't get a deprecation warning.

Paulw11
  • 108,386
  • 14
  • 159
  • 186
  • I know how to cast a couple of things, but that one is a mystery to me. How would you do that, please ? – Clararhea Oct 09 '14 at 20:53
  • I realised my original answer was incorrect anyway once I actually got in front of Xcode - I have updated it – Paulw11 Oct 09 '14 at 21:12
  • I thought I added a comment last night to thank you but it seems to have gone away.That definitely works. – Clararhea Oct 10 '14 at 07:50
  • Yes, the iOS 8 doc has been updated with `Use the identifier property instead.` – Alexander Farber Jan 03 '15 at 22:11
  • But value of identifier is changing for same device. – Mrug Aug 13 '15 at 04:57
  • 3
    Now `identifier` is marked as depreciated as well! https://developer.apple.com/library/prerelease/ios/documentation/CoreBluetooth/Reference/CBPeripheral_Class/index.html#//apple_ref/occ/instp/CBPeripheral/identifier – Nestor Aug 23 '15 at 19:30
  • I believe that this is a documentation error. The text for `identifier` doesn't seem to expand properly and I don't receive a deprecation warning in Xcode 7b5 – Paulw11 Aug 24 '15 at 01:58
  • Same here. No deprecated warning in Xcode beta for identifier. I do believe it is documentation error. – Summer Aug 24 '15 at 15:29
  • @Nestor I noticed that as well and I was also wondering if that's a mistake in the documentation... especially since there's no "Use XYZ instead" on that property. – Evan K. Stone Oct 02 '15 at 20:08
  • 1
    @Nestor this might clear things up... Nick Brook over on the Core Bluetooth mailing list pointed out that "The new identifier property is on the new CBPeer superclass" -- so it's still there, it just got promoted up the class hierarchy to CBPeer. Whew! – Evan K. Stone Oct 02 '15 at 20:12
  • Just verified it. If you look at CBPeer.h, sure enough... identifier is a property of that class, from which CBCentral and CBPeripheral inherit. That certainly was an interesting mystery to figure out! ;) – Evan K. Stone Oct 02 '15 at 20:18
  • Next time somebody tells me to read the docs rather than post on SO, I'm linking them here. – Nestor Oct 02 '15 at 20:38
3

So, just in case anybody reads this: Here is the general way to find out what to use instead of the deprecated API call.
1) Mark the deprecated call
2) Right click "Jump to definition"
3) Read what it says there.

In the case of UUID which was asked here, the answer would be 2 lines below:

@property (readonly, nonatomic) NSUUID *identifier NS_AVAILABLE(NA, 7_0);
Nazik
  • 8,696
  • 27
  • 77
  • 123
ChrisD
  • 31
  • 1
2

You can access service UUID by CBAdvertisementDataServiceUUIDsKey in advertisementData in

- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI
ViciV
  • 303
  • 2
  • 11