[TIMOB-5237] iOS: Not passing optional param to function causes crash
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2011-11-05T15:52:07.000+0000 |
Affected Version/s | Release 1.8.0 |
Fix Version/s | Sprint 2011-37, Release 1.8.0 |
Components | iOS |
Labels | branch-5062, regression |
Reporter | Matthew Congrove |
Assignee | Sabil Rahim |
Created | 2011-09-08T17:42:46.000+0000 |
Updated | 2014-06-19T12:46:30.000+0000 |
Description
There's an inconsistency between in-browser JS and Titanium where not passing a parameter to a function, then referencing that parameter, causes a red screen.
// TITANIUM
function getList(name, value) {
return Titanium.App.Properties.getList(name, value);
}
var a = getList("key", "value"); // Works
var b = getList("key"); // Dies: "Attempt to insert nil object"
// BROWSER
function getList(name, value) {
return whatever(name, value);
}
function whatever(name, value) { // Pretending to be Ti.App.Properties.getList()
return true;
}
var a = getList("key", "value"); // Works
var b = getList("key"); // Works
Workaround in the mean time:
It should be noted that this is used quite a bit across many apps - it's been working in Ti CI builds up until just few weeks ago. Changing all places this is used might be a huge task just for a new bug.
You could monkey patch this in your app.js so that all calls wouldn't have to be changed in an app.
Also cherry picked into branch-5062.
Tested with 1.8.0.v20110914092150 on Nexus S 2.3.4 iPhone 4.3.4 iPad 4.3.5
Standardizing summary and labels.