Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-6374] iOS: Module Template's Setter Property is Incorrect

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-02-10T00:24:22.000+0000
Affected Version/sRelease 1.8.0.1
Fix Version/sSprint 2012-02, Release 2.0.0, Release 1.8.1
ComponentsiOS
Labelsparity
ReporterDawson Toth
AssigneeMax Stepanov
Created2011-11-30T08:12:05.000+0000
Updated2012-03-04T22:12:47.000+0000

Description

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

Comments

  1. Dawson Toth 2011-11-30

    Pull request sent, annotated in description.
  2. Wilson Luu 2012-01-23

    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)

JSON Source