[TIMOB-25960] Hyperloop: iOS - Property returns function instead of string
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Reopened |
Resolution | Unresolved |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Hyperloop |
Labels | engReviewed, hyperloop, ios |
Reporter | Andreas Schräder |
Assignee | Jan Vennemann |
Created | 2018-01-05T00:08:13.000+0000 |
Updated | 2019-06-18T15:52:50.000+0000 |
Description
Instead of strings, I only get functions that produce errors when processing the Hyperloop results. That said: console.log prints the correct value for the unmodified variable. I need to access the string that console.log prints.
var HMHomeManager = require('HomeKit/HMHomeManager');
var NSArray = require('Foundation/NSArray');
var HMHomeManagerDelegate = Hyperloop.defineClass('HMHomeManagerDelegate', 'NSObject');
HMHomeManagerDelegate.addMethod({
selector: 'homeManagerDidUpdateHomes:',
instance: true,
arguments: ['HMHomeManager'],
callback: function(sender) {
if (this.homeManagerDidUpdateHomes) {
this.homeManagerDidUpdateHomes(sender);
}
}
});
var HMHome = require('HomeKit/HMHome');
var delegate = new HMHomeManagerDelegate();
delegate.homeManagerDidUpdateHomes = function(sender) {
var name = sender.primaryHome.name;
console.log('name: '+ name);
console.log(JSON.stringify({"name":"name","value":name}));
};
var homeManager = new HMHomeManager();
homeManager.delegate = delegate;
Prints:
[INFO] : name: My Home
Should print:
[INFO] : name: My Home
[INFO] : {"name":"name","value":"My Home"}
Attachments
File | Date | Size |
---|---|---|
HomeKitAccess.zip | 2018-01-10T20:32:49.000+0000 | 9299327 |
Hello [~aschräder], Thanks for sharing with us. Can you please share a simple test case to reproduce this on our end. Also share your environment details. Best
Hi Mostafizur, I think the below code should be the minimal test case to reproduce the behaviour. Putting this into the index.js should produce the described behaviour:
With regards to environment details: MacOS, iOS, HomeKit, Appcelerator Studio 5.0.0. (all the latest versions). The hyperloop module is activated. As build properties I have selected the Titanium SDK 6.3.0.GA. in the tiapp.xml I have configured the necessary properties and entitlements:
Hope this helps reproducing the behaviour. In case anything is missing, please let me know.
Hello, Please create a sample Alloy project with the reproducible code and attach the file in here. Thanks.
This is not a Hyperloop issue, please read the native documentation more carefully. I see this kind of issues popping up more and more. Some background for your issue: - The issue is in
uuid
, notname
-uniqueIdentifier
returns aUUID
instance, not String as documented [here](https://developer.apple.com/documentation/homekit/hmhome/1620243-uniqueidentifier) - Access it as a String by usinguniqueIdentifier.uuidString
as documented [here](https://developer.apple.com/documentation/foundation/uuid/1779712-uuidstring) -toString
is no property but a function (e.g.toString()
). It is no native method but a JavaScript method that only works with proper JavaScript types likeNumber
andArray
as documented [here](https://www.w3schools.com/jsref/jsref_tostring_number.asp)Please reopen the issue as this has nothing to do with the uniqueIdentifier or the use of toString(). I have cleaned the case description in order to avoid distraction - albeit at the cost that the error message disappears and the problem only occurs 'silently'. sender.primaryHome.name is a string and does not behave as a string would. @Hans Knöchel: while your explanations around the UUID are what I would expect based on the documentation, the evidence is that console.log with uniqueIdentifier.uuidString prints 'undefined' whereas console.log with uniqueIdentifier prints the actual value.
@Sharif AbuDarda: I have attached a sample project 'HomeKitAccess' as you suggested.
[~aschräder] The Obj-C usage (which Hyperloop is generated from) is
UUIDString
, notuuidString
which is [documented](https://developer.apple.com/documentation/foundation/nsuuid/1416585-uuidstring?language=objc) as well. And the reason whysender.primaryHome.name
prints correctly is likely because it prints the description as the native world does as well. If Hyperloop really unwraps this correctly, you should still be able to receive it viasender.primaryHome.name.description
.@Hans Knöchel Thanks for the prompt response. I had copied the
from your prior post, but the result with
is exactly the same. I've tested the your hypothesis with regards to the description. It turns out that Hyperloop apparently does not unwrap this as expected. With
it prints:
Interestingly, this is the same as result that I get with
. I could understand why the description of the
property prints
, but why would
print
? I take advantage and address another problem I encounter, which may be related: I seem to be unable to access an array (an
) with Hyperloop. If I define name as any of the three below properties:
it prints nothing at all. I hope it's just me coding it incorrectly. Otherwise it would be hard to implement a HomeKit app without improvements in Hyperloop...
@Shak Hossain: Can you please re-open this issue? This is neither invalid nor resolved! Thanks!
Hello [~aschräder], Can you test the issue on latest SDK and let us know how it goes.
I have just tested it with 7.1.0 - and the result is unchanged. The problem continues to exist and needs to be fixed. Andreas
Hey there! We will further investigate this and I have moved it to TIMOB. We will let you know once it's scheduled.