{ "id": "145763", "key": "TIMOB-19121", "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": "2017-06-29T19:08:53.000+0000", "created": "2015-03-15T08:46:20.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [ "ios", "string.format" ], "versions": [], "issuelinks": [], "assignee": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "updated": "2017-08-16T01:10:50.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": "I am relying heavily on String.format in combination with a Strings.xml Files to customize the user experience. This worked perfect until I recently switched from SDK 3.3 to 3.5 and iOS SDK 8.2.\r\n\r\nRunning an application in a simulator (8.1 or 8.2) from within the Titanium Studio leads to a crash without any feedback or the Strings.xml content not being applied.\r\n\r\nRunning the same application from within XCode in the same simulator version leads to the follow EXC_BAD_ACCESS in KrollContext.m. Screenshot attached.\r\n\r\nThe corresponding function call in Javascript looks like this:\r\n\r\n{code:javascript}\r\n\r\nfilterTimeframeLabel.setText( String.format(L('Option_Filter_Timeframe_Details'), Util2.formatDate(transactionFilter.timeframe[0], 'DD.MM.YYYY'), Util2.formatDate(transactionFilter.timeframe[1], 'DD.MM.YYYY')) );\r\n\r\n{code}\r\n\r\nCompiling an AdHoc and running the same application on a device works perfectly. This just applies to the simulator.\r\n\r\n\r\nIn addition also simple String.Formats fail:\r\n\r\n{code}\r\nlabel.setText ( String.format('%d test', 99) );\r\n{code}\r\n\r\nDisplays \"99\" in the simulator and \"99 test\" on the device.", "attachment": [ { "id": "54450", "filename": "Bildschirmfoto 2015-03-15 um 09.39.39.png", "author": { "name": "favo", "key": "favo", "displayName": "Mario", "active": true, "timeZone": "Europe/Berlin" }, "created": "2015-03-15T08:46:21.000+0000", "size": 278159, "mimeType": "image/png" } ], "flagged": false, "summary": "iOS: String.format crashes on iOS Simulator", "creator": { "name": "favo", "key": "favo", "displayName": "Mario", "active": true, "timeZone": "Europe/Berlin" }, "subtasks": [], "reporter": { "name": "favo", "key": "favo", "displayName": "Mario", "active": true, "timeZone": "Europe/Berlin" }, "environment": "Simulator, iOS 8.2, 3.5.1.GA", "comment": { "comments": [ { "id": "346307", "author": { "name": "sliang", "key": "sliang", "displayName": "Shuo Liang", "active": true, "timeZone": "Asia/Harbin" }, "body": "HI,\r\n\r\nPlease provide a simple test case to reproduce your crashes issue, That will be really helpful. Thanks\r\n\r\nOn the other hand, about missing text after %dm it is a known issue, ref: TIMOB-18640\r\n\r\nRegards,\r\nShuo", "updateAuthor": { "name": "sliang", "key": "sliang", "displayName": "Shuo Liang", "active": true, "timeZone": "Asia/Harbin" }, "created": "2015-03-18T01:24:16.000+0000", "updated": "2015-03-18T01:24:16.000+0000" }, { "id": "353941", "author": { "name": "james.falkner", "key": "james.falkner", "displayName": "James Falkner", "active": true, "timeZone": "America/New_York" }, "body": "Can confirm. Here's a simple test case:\r\n\r\n{noformat}\r\n$ mkdir /tmp/foo\r\n$ cd /tmp/foo\r\n$ ti create --name foo --id foo --workspace-dir `pwd`\r\n$ cd foo\r\n$ vi Resources/app.js\r\n{noformat}\r\n\r\nRemove all contents of {{app.js}} and replace with:\r\n\r\n{noformat}\r\nString.format(\"%2$d %1$s\", \"foo\", 2);\r\n{noformat}\r\n\r\nThen run it in the simulator:\r\n\r\n{noformat}\r\n$ ti build --platform iphone --target simulator --device-id FF5C5A2C-2D8C-4ED2-A95A-AFD23AEE8F15 --sim-type iphone\r\n{noformat}\r\n\r\nIt will crash badly after the Appcelerator default splash screen.\r\n\r\nSee, the second argument is the \"d\" and the first is the \"s\". {{String.format(\"%1$s %2$d\", \"foo\", 2);}} works fine. {{String.format(\"%2$d %1$s\", \"foo\", 2);}} fails. And it only fails in the simulator. This happens in both 3.5.1.RC and 4.0.0.RC4.\r\n\r\n", "updateAuthor": { "name": "james.falkner", "key": "james.falkner", "displayName": "James Falkner", "active": true, "timeZone": "America/New_York" }, "created": "2015-06-01T00:45:40.000+0000", "updated": "2015-06-01T00:46:57.000+0000" }, { "id": "423041", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "I have validated the issue with our latest SDK and {{String.format(\"%2$d %1$s\", \"foo\", 2)}} still crashes, while {{String.format(\"%1$d %2$s\", 2, \"foo\")}}, so I am wondering why someone would specify the arguments in the reversed order. The bad access has to do with exactly that and would need to be adjusted for this special case accordingly. ", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2017-06-28T15:14:42.000+0000", "updated": "2017-06-28T15:14:42.000+0000" }, { "id": "423191", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "The issue is because the formats are structured incorrectly. When using the correct format-indexing, everything works. Besides that, the initial ticket request was already fixed before and does not occur anymore (tested on both Simulator and device).", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2017-06-29T19:08:53.000+0000", "updated": "2017-06-29T19:08:53.000+0000" }, { "id": "426747", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Closing with reference to the above observations.", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-08-16T01:10:50.000+0000", "updated": "2017-08-16T01:10:50.000+0000" } ], "maxResults": 8, "total": 8, "startAt": 0 } } }