Titanium JIRA Archive
Appcelerator Community (AC)

[AC-5772] Hyperloop iOS - Setting Array value to required Class setting string

GitHub Issuen/a
TypeBug
Priorityn/a
StatusResolved
ResolutionInvalid
Resolution Date2018-06-18T11:19:15.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsHyperloop
Labelsalloy, hyperloop, ios
ReporterDavid van de Meer
AssigneeShak Hossain
Created2018-06-18T03:31:19.000+0000
Updated2018-06-18T13:47:55.000+0000

Description

In Hyperloop I have required and initiated a "config class" as part of the framework. The problem I have is that when I set an array to one of the config class variables it gets set to the class as a string and not an array, even when creating an NSArray it does not get set. The only workaround has been to set the value as a an array inside an array?! Example: [["value1","value2"]] So I require the config class:
// require CountlyConfig
var CountlyConfigClass = require('Countly/CountlyConfig');
var CountlyConfig = new CountlyConfigClass();
I then set variables on the config class as follows, these work just fine:
CountlyConfig.appKey = "123124";
CountlyConfig.host = "http://www.host.com";
The problem happens when setting array as follows:
CountlyConfig.features = ["crash","views"];
This does not work as the Config class thows an error saying it expects an NSArray, after many hours I was able to set the value as follows:
CountlyConfig.features = [["crash","views"]];
Steps to reproduce: 1. Create new alloy hyperloop enabled project 2. In your podfile, add -> pod 'Countly', '18.04' 3. In a alloy.js, put this:
// require CountlyConfig
var CountlyConfigClass = require('Countly/CountlyConfig');
var CountlyConfig = new CountlyConfigClass();

// set config vars
CountlyConfig.appKey = "123124";
CountlyConfig.host = "http://www.host.com";
CountlyConfig.features = ["crash","views"];

4. Try and build project with the environment mentioned above Podfile:

This is required for CocoaPods 1.x

install! 'cocoapods', :integrate_targets => false platform :ios, '8.0' use_frameworks! target 'alloy-hyperloop' do pod 'Countly', '18.04' end

Comments

  1. Hans Knöchel 2018-06-18

    A (non-typed) JS-array is different to the (typed) native Array, e.g.
       var nativeArray = NSArray.arrayWithObjects('crash', 'views', null);
       
    The "null" is for terminating the variadic method structure.

JSON Source