[TIMOB-20506] iOS: Ti.App.Properties.setList failes when array element is object with null property
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | Critical |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2016-10-12T04:16:48.000+0000 |
| Affected Version/s | Release 5.1.1 |
| Fix Version/s | Release 6.1.0 |
| Components | iOS |
| Labels | ios, list, properties |
| Reporter | Jason Knight |
| Assignee | Hans Knöchel |
| Created | 2016-03-02T00:21:01.000+0000 |
| Updated | 2016-11-17T18:44:40.000+0000 |
Description
When trying to set a list, via "Ti.App.Properties.setList", with an object that has a null value property, I get an Application Error: "Attempt to insert non-property list"
var names = [{
name: "One"
}, {
name: null
}];
Ti.App.Properties.setList("names", names);
This error does not happen on Android 6.0.1.
*Note:* This issue seems similar to [TIMOB-13127]
This should be in TIMOB and not TC.
I guess this won't get fixed because nobody else has bothered to report it?
I can report it again. Still in SDK 5.4.0
PR (Core-SDK): https://github.com/appcelerator/titanium_mobile/pull/8371 PR (Unit-Test): https://github.com/appcelerator/titanium-mobile-mocha-suite/pull/4 Using a generatic attempt too loop through dictionary-values in
setListto convert betweennull- andNSData-values that are required by the internal iOS-API. The test-case contains all kind of possible values, from dictionary (object) over null, undefined, string, number and boolean. Demo:Expected result: - No crashes in getting and setting the property-list -var win = Ti.UI.createWindow({ backgroundColor: "#fff" }); var btn1 = Ti.UI.createButton({ title: "Set list", top: 30 }); btn1.addEventListener("click", function() { var names = [{ name: "One" }, { name: 1 }, { name: "" }, null, { name: true }, 1, "", null, false]; Ti.App.Properties.setList("names", names); }); var btn2 = Ti.UI.createButton({ title: "Get list", top: 60 }); btn2.addEventListener("click", function() { Ti.API.warn(Ti.App.Properties.getList("names", [])); }); win.add(btn1); win.add(btn2); win.open();null- andundefined-values are properly accepted in both setter and getterVerified fixed, using: MacOS 10.12 (16A323) Studio 4.8.0.201611121409 Ti SDK 6.1.0.v20161117072812 Appc NPM 4.2.9-1 Appc CLI 6.1.0-13 Alloy 1.9.4 Xcode 8.1 (8B62) Arrays objects with null/undefined properties can be set and retrieved with setList and getList, without error.