[TIMOB-24383] Hyperloop: iOS - Objects returned from NSArray/NSSet unusable
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2017-04-19T07:22:13.000+0000 |
Affected Version/s | Hyperloop 2.0.0 |
Fix Version/s | Hyperloop 2.1.0 |
Components | Hyperloop, iOS |
Labels | n/a |
Reporter | Jan Vennemann |
Assignee | Jan Vennemann |
Created | 2017-02-08T02:44:52.000+0000 |
Updated | 2017-04-19T22:34:33.000+0000 |
Description
Objects that are added to
NSArray
or NSSet
in native code and then retrieved via Hyperloop cannot properly be accessed. All properties are undefined and no methods can be called.
*Steps to reproduce the behavior*
1. Create a new classic app with Hyperloop enabled
2. Extract the source contained in the attached zip file to project's src
directory
3. Place attached appc.js into the project root folder
4. Add this code to app.js
var Place = require('Test/Place');
var LikelihoodList = require('Test/LikelihoodList');
var l1 = new LikelihoodList();
Ti.API.debug('');
Ti.API.debug('### Test 1 ###');
var p0 = l1.place;
Ti.API.debug('Native - Single property');
Ti.API.debug('Retrieved object: ' + p0);
Ti.API.debug('Name property: ' + p0.name);
Ti.API.debug('');
Ti.API.debug('### Test 2 ###');
var p1 = Place.cast(l1.likelihoods.objectAtIndex(0));
Ti.API.debug('Native - Added to NSArray');
Ti.API.debug('Retrieved object: ' + p1);
Ti.API.debug('Name property: ' + p1.name);
var NSMutableArray = require('Foundation/NSMutableArray');
var NSArray = require('Foundation/NSArray');
var l2 = new NSMutableArray();
Ti.API.debug('');
Ti.API.debug('### Test 3 ###');
var p = Place.alloc().initWithNameAndRating("Test2", 1.0);
l2.addObject(p);
var p2 = Place.cast(l2.objectAtIndex(0));
Ti.API.debug('HL - Create new array, add place and retrieve');
Ti.API.debug('Retrieved object: ' + p2);
Ti.API.debug('Name property: ' + p2.name);
Ti.API.debug('');
Ti.API.debug('### Test 4 ###');
var l3 = new NSMutableArray();
l1.fill(l3);
var p3 = Place.cast(l3.objectAtIndex(0));
Ti.API.debug('HL/Native - Create new array (HL) and add place (Native)');
Ti.API.debug('Retrieved object: ' + p3);
Ti.API.debug('Name property: ' + p3.name);
*Actual behavior*
Test cases 2 and 4 show Name property: undefined
because the object has no methods or properties mapped.
*Expected behavior*
All test cases print the value of the object's name property
Attachments
File | Date | Size |
---|---|---|
appc.js | 2017-03-15T02:01:12.000+0000 | 302 |
Test.zip | 2017-03-15T02:01:55.000+0000 | 1497 |
PR (master): https://github.com/appcelerator/hyperloop.next/pull/157 PR (2_1_X): https://github.com/appcelerator/hyperloop.next/pull/158
Tested with this environment: Node Version: 6.10.1 NPM Version: 3.10.10 Mac OS: 10.12.4 Appc CLI: 6.2.0 Appc CLI NPM: 4.2.9 Titanium SDK version: 6.0.3.GA Appcelerator Studio, build: 4.8.1.201612050850 Xcode 8.2.1 Hyperloop 2.1.0 4/19 commit *1bd4 I tested with the above environment, and with the demo code shown in the description. I created an src folder at the root, and extracted the appropriate zip. Testcase #2 and #4 now print's values of the object property names: