[TIMOB-25034] Hyperloop: Properties from object in NSArray are undefined
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Duplicate |
Resolution Date | 2017-11-15T14:11:28.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Hyperloop |
Labels | CLBeacon, NSArray, hyperloop |
Reporter | Sandro Lain |
Assignee | Jan Vennemann |
Created | 2017-07-28T08:17:32.000+0000 |
Updated | 2017-11-15T14:11:28.000+0000 |
Hey there, thank for the fixes, this is great! Can you open a Pull Request on the repository, so we can merge your changes? That's how it stays your contribution. If not interested, we can also schedule to make the change ourselves. Thanks again!
[~sandrolain], can you please try to change the following:
to
Objects from arrays are always returned wrapped as an
NSObject
by default and you need to explicitly cast them to the actual type you want to access methods and properties from. [~hknoechel], we should maybe consider printing the JS prototype name alongside the native wrapped object for clearer log outputs. I also added this to TIDOC-2811 so it will be properly documented.*Thank you!* I tried to convert objects and now the properties are visible. At first it seemed not to work. I was using Hyperloop with Liveview enabled, and it seems that some changes to the code are not up to date on the device. I do not know if it was a problem only to my running, but sometimes I still had to recompile the app to learn the changes even though I saw the app to refresh.
I've encountered another problem getting access to the properties of Hyperloop instances. I'm developing an application that uses Core Bluetooth in iOS. When I look for information about services (instance of CBService) of a peripheral sometimes the value of "UUID" property is "undefined". If I try to get the same property by casting it to the type from which it is derived (CBAttribute) I can read the popriety correctly. Apple references: https://developer.apple.com/documentation/corebluetooth/cbservice?language=objc https://developer.apple.com/documentation/corebluetooth/cbattribute?language=objc https://developer.apple.com/documentation/corebluetooth/cbperipheral?language=objc Services are read after the invocation of: https://developer.apple.com/documentation/corebluetooth/cbperipheraldelegate/1518744-peripheral?language=objc After the call to: https://developer.apple.com/documentation/corebluetooth/cbperipheral/1518706-discoverservices?language=objc What's strange is that the "isPrimary" property of the CBService instance becomes "undefined" after I ran the second cast at CBAttribute, before cast it was valued! Report the part of the code involved (I can not return all the code because it is too large and involves the work for one of my clients):
The console log: {noformat} [INFO] : CBService.UUID: undefined [INFO] : CBService.isPrimary: 1 [INFO] : CBAttribute.UUID: Device Information [INFO] : CBService.isPrimary: undefined [INFO] : CBService.UUID: Battery [INFO] : CBService.isPrimary: 1 [INFO] : CBAttribute.UUID: Battery [INFO] : CBService.isPrimary: undefined {noformat} Similarly after calling "peripheral:didDiscoverCharacteristicsForService:error:" I should have the "characteristics" (NSArray) property of the CBService instance valued but I get
{noformat} [INFO] :
[~sandrolain], thanks for all your input. I created TIMOB-25069 based on your findings and will further investigate the issue you are seeing there. Can you please create a new ticket for the other issue you are experiencing with unreported exceptions and create a minimal working example so we can reproduce it? Thanks a lot!
Closing as a duplicate of TIMOB-25069 which covers the root issue of this ticket with an easier to reproduce example that is not tied to Bluetooth.