{ "id": "79342", "key": "TIMOB-5167", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": { "id": "10100", "description": "This issue won't be actioned.", "name": "Won't Do" }, "resolutiondate": "2020-01-09T19:22:56.000+0000", "created": "2011-08-16T14:51:19.000+0000", "priority": { "name": "Low", "id": "4" }, "labels": [ "core" ], "versions": [], "issuelinks": [], "assignee": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2020-01-09T19:22:56.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "When you attach an object to a Window on iOS the object is immutable, yet on Android it works fine. For example, win.myCustomObject = { id: val } works as expected. However, when you then try and change a value within that object, the changes are never made i.e. win.myCustomObject.id = newVal, the id stays the same.\r\n\r\nCode example requires two files:\r\n\r\n{code:lang=javascript|title=app.js}\r\nvar win = Ti.UI.createWindow({\r\n backgroundColor: '#000',\r\n url: 'window_object_win.js',\r\n layout:'vertical'\r\n});\r\n\r\nwin.data = {\r\n text: 'Initialized'\r\n};\r\n\r\nwin.open();\r\n\r\nwin.addEventListener('modifyData', function() {\r\n win.data.text = 'This should be updated if this object is mutable';\r\n win.fireEvent('dataUpdated');\r\n});\r\n\r\nwin.addEventListener('replaceData', function() {\r\n win.data = { text: 'If the data has changed now then replacing the entire data object works ' };\r\n win.fireEvent('dataUpdated');\r\n});\r\n{code}\r\n\r\n{code:javascript|title='window_object_win.js'}\r\nvar modifyButton = Ti.UI.createButton({\r\n title: 'Modify window .data object',\r\n top: 60,\r\n width: 250,\r\n height: 80\r\n});\r\n\r\nvar replaceButton = Ti.UI.createButton({\r\n title: 'Replace window .data object',\r\n top: 60,\r\n width: 250,\r\n height: 80\r\n});\r\n\r\nvar label = Ti.UI.createLabel({\r\n color: '#FFF',\r\n top: 20,\r\n height: 200\r\n});\r\n\r\nTi.UI.currentWindow.add(modifyButton);\r\nTi.UI.currentWindow.add(replaceButton);\r\nTi.UI.currentWindow.add(label);\r\n\r\nmodifyButton.addEventListener('click', function() {\r\n Ti.UI.currentWindow.fireEvent('modifyData');\r\n});\r\n\r\nreplaceButton.addEventListener('click', function() {\r\n Ti.UI.currentWindow.fireEvent('replaceData');\r\n});\r\n\r\nvar counter = 0;\r\n\r\nvar updateLabelFromData = function() {\r\n label.text = 'Text (' + counter++ + ' presses) = ' + Ti.UI.currentWindow.data.text;\r\n};\r\n\r\nTi.UI.currentWindow.addEventListener('dataUpdated', updateLabelFromData);\r\n\r\nupdateLabelFromData();\r\n{code}\r\n\r\nTo replicate this issue with this code example, load up the app, click on the bottom button (to modify values) and you will see that the value does not change. However, if you click on the button above that which replaces the entire object on the window, it works fine. On Android both buttons work as expected.", "attachment": [], "flagged": false, "summary": "iOS: Immutable objects on Window object", "creator": { "name": "matthew.oriordan", "key": "matthew.oriordan", "displayName": "Matthew O'Riordan", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "matthew.oriordan", "key": "matthew.oriordan", "displayName": "Matthew O'Riordan", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "Titanium SDK version: 1.7.2.97c3689.\r\nPlatform & version: iOS 4.3.2, OSX 10.7 (Lion)\r\nDevice Details: iOS simulator and iOS device\r\nHost Operating System: OSX 10.7\r\nTitanium Studio version: Titanium Studio, build: 1.0.2.201107130739", "comment": { "comments": [ { "id": "164079", "author": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "body": "Matthew\r\n\r\nCan you see if there are any significant messages output to the log, and include them in your ticket in a code block, if you do?\r\n\r\nMany thanks", "updateAuthor": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "created": "2011-08-25T16:31:16.000+0000", "updated": "2011-08-25T16:31:16.000+0000" }, { "id": "164123", "author": { "name": "matthew.oriordan", "key": "matthew.oriordan", "displayName": "Matthew O'Riordan", "active": true, "timeZone": "America/Los_Angeles" }, "body": "There aren't any messages related to this code.", "updateAuthor": { "name": "matthew.oriordan", "key": "matthew.oriordan", "displayName": "Matthew O'Riordan", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-08-26T05:01:39.000+0000", "updated": "2011-08-26T05:01:39.000+0000" }, { "id": "209023", "author": { "name": "jamesdlow", "key": "jamesdlow", "displayName": "James David Low", "active": true, "timeZone": "Europe/London" }, "body": "I get this same issue when passing variables as part of a window AND when using Ti.App.\r\n\r\nI do something like:\r\nvar someObject = {};\r\nTi.App.refToSomeObject = someObject;\r\n\r\nIf I make changes to someObject in say a callback from an HTTP request and then another window accesses Ti.App.refToSomeObject, the changes aren't propagated.", "updateAuthor": { "name": "jamesdlow", "key": "jamesdlow", "displayName": "James David Low", "active": true, "timeZone": "Europe/London" }, "created": "2012-07-23T17:47:53.000+0000", "updated": "2012-07-23T17:47:53.000+0000" }, { "id": "209024", "author": { "name": "jamesdlow", "key": "jamesdlow", "displayName": "James David Low", "active": true, "timeZone": "Europe/London" }, "body": "Someone else has this same problem here:\r\nhttp://developer.appcelerator.com/question/65211/data-between-contexts-reference-vs-titaniumappproperties-#answer-129821", "updateAuthor": { "name": "jamesdlow", "key": "jamesdlow", "displayName": "James David Low", "active": true, "timeZone": "Europe/London" }, "created": "2012-07-23T17:48:53.000+0000", "updated": "2012-07-23T17:48:53.000+0000" }, { "id": "209028", "author": { "name": "jamesdlow", "key": "jamesdlow", "displayName": "James David Low", "active": true, "timeZone": "Europe/London" }, "body": "I found an issue in the support related to this:\r\nhttp://support.appcelerator.com/tickets/XIY-29136-551/report\r\n\r\nIn case you can't see it, Nolan Wright says:\r\n\"...attach properties to your window objects as you create them. the downside here is that each one is a copy so they are not the same variable - i.e., a change in one will not be reflected in the others.\"\r\n", "updateAuthor": { "name": "jamesdlow", "key": "jamesdlow", "displayName": "James David Low", "active": true, "timeZone": "Europe/London" }, "created": "2012-07-23T19:25:54.000+0000", "updated": "2012-07-23T19:25:54.000+0000" }, { "id": "209030", "author": { "name": "ngupta", "key": "ngupta", "displayName": "Neeraj Gupta", "active": true, "timeZone": "America/Los_Angeles" }, "body": "@James - Please let me know the SDK version you are using.", "updateAuthor": { "name": "ngupta", "key": "ngupta", "displayName": "Neeraj Gupta", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-07-23T20:11:30.000+0000", "updated": "2012-07-23T20:11:30.000+0000" }, { "id": "209133", "author": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "body": "This is caused by long-standing critical bug TIMOB-2392, which requires a significant investment in changing the iOS platform internals.", "updateAuthor": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-07-24T09:44:34.000+0000", "updated": "2012-07-24T09:44:34.000+0000" }, { "id": "453562", "author": { "name": "ahutton", "key": "ahutton", "displayName": "Alan Hutton", "active": true, "timeZone": "America/Los_Angeles" }, "body": "It has been decided that this issue should be closed as “Won’t do.” This issue is out of date with our current supported SDK release (7.5.2.GA as of the date of closure), and out of date with mobile OS versions. Updating, or creating code may not reproduce the issue reported, or be a valid test case.\r\n\r\nIf community members feel that the issue is still valid, please create a new ticket. Please reference this closed ticket number, include SDK used, comments, and code that demonstrates/reproduces the issue.", "updateAuthor": { "name": "ahutton", "key": "ahutton", "displayName": "Alan Hutton", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2020-01-09T19:22:56.000+0000", "updated": "2020-01-09T19:22:56.000+0000" } ], "maxResults": 8, "total": 8, "startAt": 0 } } }