Problem
The setter example property in the default module template is written incorrectly, so it ends up hiding the getter.
Test app.js
Run the following with the module for the conclusions to follow:
var test = require('ti.test');
var win = Titanium.UI.createWindow({
backgroundColor:'white'
});
win.add(Titanium.UI.createLabel({
text: test.exampleProp
}));
test.exampleProp = 'Goodbyte, module!';
win.open();
Why It Doesn't Work
The setter doesn't follow conventions, so it hides the getter:
-(id)exampleProp
{
NSLog(@"exampleProp called!");
return @"Hello, world!";
}
-(void)exampleProp:(id)value
{
NSLog(@"setExampleProp called!");
}
The label will display "[object ti.test]" (or whatever the ID of your module is), not the expected "Hello, world!".
How to Fix
The setter should be prefixed with "set", as in the following:
-(void)setExampleProp:(id)value
{
NSLog(@"setExampleProp called!");
}
With that in hand, everything works as expected.
Pull Request
https://github.com/appcelerator/titanium_mobile/pull/788
Pull request sent, annotated in description.
Closing bug. Verified fix on: SDK build: 1.9.0.v20120121223134 Titanium Studio, build: 1.0.8.201201210622 Xcode: 4.2 OS: Mac OS X Lion (10.7.2) Device: iPhone 4S Verizon (5.0.1)