Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-10578] iOS: Property of a proxy is Read-Only

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionInvalid
Resolution Date2020-09-03T13:14:34.000+0000
Affected Version/sRelease 3.0.0, Release 3.1.0, Release 3.2.0, Release 3.2.1
Fix Version/sn/a
ComponentsiOS
LabelsSupportTeam, api, parity
ReporterEduardo Gomez
AssigneePedro Enrique
Created2012-08-23T13:38:05.000+0000
Updated2020-09-03T13:14:34.000+0000

Description

Issue

Looks like a property of a proxy is read only in iOS

Droid console output

[INFO][TiAPI   (  338)]  Should say "first": first
[INFO][TiAPI   (  338)]  Should say "second": second

iOS console output

[INFO] Should say "first": first
[INFO] Should say "second": first

Simple repro snippet

var win = Ti.UI.createWindow({
	backgroundColor: 'white'
});

var obj = {
	_data: [
		{one: 'one'},
		{two:'two'},
		{three:'three'},
		{four:'four'},
		{five:'five'}
	],
	width:100,
	height: 100,
	backgroundColor: 'red'
}

var view = Ti.UI.createView({
	_data: [
		{one: 'one'},
		{two:'two'},
		{three:'three'},
		{four:'four'},
		{five:'five'}
	],
	width:100,
	height: 100,
	backgroundColor: 'red',
	_myname:[ 'first' ] // this is view._myname[0]
});

win.add(view);

win.open();

Ti.API.info('Should say "first": ' + view._myname[0]);
view._myname[0] = 'second';
Ti.API.info('Should say "second": ' + view._myname[0]);

Tested on

iOS 5.1 simulator Droid Razr 2.3.5

Comments

  1. jithinpv 2013-03-27

    Issue reproduces Tested with Titanium Studio, build: 3.0.1.201212181159 Titanium SDK version: 3.1.0 Titanium SDK version: 3.0.2 iOS iPhone Simulator: iOS SDK version: 6.0
  2. Pedro Enrique 2015-02-10

    Just a comment while we look into this. A Titanium proxy is not a regular JS object. Any custom properties added to a proxy are internally copied and converted into native value, such as NSArray, for example. The values of these properties become read-only until overwritten. To solve this issue for now, do the following
       Ti.API.info('Should say "first": ' + view._myname[0]);
       var newObject = view._myname;
       newObject[0] = 'second';
       view._myname = newObject;
       Ti.API.info('Should say "second": ' + view._myname[0]);
       
  3. Rene Pot 2020-09-03

    Closing for cleaning up legacy tickets purpose. As mentioned above, this is expected bevariour. Workaround
       Ti.API.info('Should say "first": ' + view._myname[0]);
       let myname = view._myname;
       myname[0] = "second";
       view._myname = myname;
       Ti.API.info('Should say "second": ' + view._myname[0]);
       

JSON Source