[TIMOB-24538] iOS: Setting Ti.UI.ListItem "bindId" property to reserved identifier should fail gracefully
| GitHub Issue | n/a |
|---|---|
| Type | Improvement |
| Priority | Critical |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2017-05-19T14:14:19.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | Release 6.2.0 |
| Components | iOS |
| Labels | n/a |
| Reporter | Hans Knöchel |
| Assignee | Hans Knöchel |
| Created | 2017-03-27T20:52:25.000+0000 |
| Updated | 2017-05-19T14:16:47.000+0000 |
Description
There are properties like "badge" and "constants" that are private API of the " is reserved by the system, please choose a different name and try again.". Easy one.
UITableViewCell, which we subclass with our TiUIListItem. Setting the bindId to those values and trying to update the underlaying key-paths afterwards will cause a crash like "this class is not key value coding-compliant for the key color." which doesn't say anything to the Titanium developer. Instead, we should show a modal error saying "The bindId "
PR: https://github.com/appcelerator/titanium_mobile/pull/8912
[~hansknoechel] Can you give a Test Case ?
You can just create a new list item template and name it with a reserved. I had a test-case and list of reserved words I tested with, but I forgot it. Let me provide it again tomorrow. *EDIT*: Try the bindId
badgeand set atextto it. It will try to set [this property](https://github.com/nst/iOS-Runtime-Headers/blob/master/Frameworks/UIKit.framework/UITableViewCell.h#L19) (which is a pretty nice property and stuff, but still private API causing the crash.Test Case:
var win = Ti.UI.createWindow({ backgroundColor: '#fff' }); var myTemplate = { childTemplates: [{ type: 'Ti.UI.Label', bindId: 'badge', properties: { height: 100, width:200 } }] }; var list = Ti.UI.createListView({ templates:{'template':myTemplate}, defaultItemTemplate: 'template', }); var sections = []; var imgSection = Ti.UI.createListSection({headerTitle:'Test Image Template'}); var listItems = []; for (var i = 0; i < 5; i++) { listItems.push({badge: {image : 'image.JPG'} }); } imgSection.setItems(listItems); sections.push(imgSection); list.setSections(sections); win.add(list); win.open();Verified as fixed, when using a reserved identifier (i.e. 'badge') for the bindId property of a ListItem an error splash screen detailing the issue is prompted. iPhone 7 10.2 Device & Simulator iPhone 5S 9.3.5 Simulator Mac OS Sierra (10.12.2) Appc NPM: 4.2.9-1 App CLI: 6.1.0 Xcode 8.2.1 Node v4.6.0 *Closing Ticket.*