Description
Following ticket ALOY-1082 I tried to create a module for ListView. While the code (pasted below) works fine using SDK 3.3.0.GA, an error is thrown when building with 3.2.3.GA.
Code
Code as proposed by [~skypanther] is the following:
lib/customlist.js
var ListView = function(args) {
this.view = Ti.UI.createListView(args);
}
ListView.prototype.addMeASectionPlease = function(items) {
var section = Ti.UI.createListSection();
section.setItems(items);
return this.view.appendSection(section);
}
ListView.prototype.getView = function() {
return this.view;
}
exports.createListView = function(args) {
return new ListView(args);
};
index.xml
<Alloy>
<Window>
<Label text="Add section" top="20" id="addButton"/>
<ListView module="customlist" top="50" id="mylist" defaultItemTemplate="template">
<Templates>
<ItemTemplate name="template">
<Label bindId="myLabel" class="myLabel"></Label>
</ItemTemplate>
</Templates>
</ListView>
</Window>
</Alloy>
index.js
$.addButton.addEventListener('click', function() {
var items = [
{myLabel: {text:'Foo'}, template:'template', properties: {backgroundColor: 'purple'}},
{myLabel: {text:'Bar'}, template:'template'},
{myLabel: {text:'Baz'}, template:'template'}
];
$.mylist.addMeASectionPlease(items);
})
$.index.open();
Error
Following the error when running the app on iOS Simulator:
[ERROR] : Script Error {
[ERROR] : backtrace = "#0 () at file:///Users/USER/Library/Application%20Support/iPhone%20Simulator/7.1/Applications/CFCEF8AE-346F-4338-AE45-9BF2B447D10B/AlloyTestListView.app/alloy.js:231";
[ERROR] : line = 59;
[ERROR] : message = "-[__NSDictionaryM krollObjectForBridge:]: unrecognized selector sent to instance 0xce8e420";
[ERROR] : sourceId = 301971840;
[ERROR] : sourceURL = "file:///Users/USER/Library/Application%20Support/iPhone%20Simulator/7.1/Applications/CFCEF8AE-346F-4338-AE45-9BF2B447D10B/AlloyTestListView.app/alloy/controllers/index.js";
[ERROR] : }
This works in SDK 3.3.0.GA and 3.4.0.GA, hence closing as won't fix.