Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24383] Hyperloop: iOS - Objects returned from NSArray/NSSet unusable

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2017-04-19T07:22:13.000+0000
Affected Version/sHyperloop 2.0.0
Fix Version/sHyperloop 2.1.0
ComponentsHyperloop, iOS
Labelsn/a
ReporterJan Vennemann
AssigneeJan Vennemann
Created2017-02-08T02:44:52.000+0000
Updated2017-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

FileDateSize
appc.js2017-03-15T02:01:12.000+0000302
Test.zip2017-03-15T02:01:55.000+00001497

Comments

  1. Jan Vennemann 2017-04-18

    PR (master): https://github.com/appcelerator/hyperloop.next/pull/157 PR (2_1_X): https://github.com/appcelerator/hyperloop.next/pull/158
  2. Abir Mukherjee 2017-04-19

    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:
       [DEBUG] :  ### Test 2 ###
       [DEBUG] :  Loading: /Users/amukherjee/Library/Developer/CoreSimulator/Devices/94D3E5A3-6FAE-4907-A16E-CC9EE3E87B77/data/Containers/Bundle/Application/585C37A0-790F-4118-8D25-8A3932C387EC/test2.app/hyperloop/foundation/nsobject, Resource: hyperloop/foundation/nsobject
       [DEBUG] :  Loading: /Users/amukherjee/Library/Developer/CoreSimulator/Devices/94D3E5A3-6FAE-4907-A16E-CC9EE3E87B77/data/Containers/Bundle/Application/585C37A0-790F-4118-8D25-8A3932C387EC/test2.app/hyperloop/foundation/nsobject.js, Resource: hyperloop/foundation/nsobject_js
       [DEBUG] :  Native - Added to NSArray
       [DEBUG] :  Retrieved object: <Place: 0x60000002d5e0>
       [DEBUG] :  Name property: Test1
       .
       .
       .
       [DEBUG] :  ### Test 4 ###
       [DEBUG] :  HL/Native - Create new array (HL) and add place (Native)
       [DEBUG] :  Retrieved object: <Place: 0x60800002e500>
       [DEBUG] :  Name property: Test5
       

JSON Source