Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24538] iOS: Setting Ti.UI.ListItem "bindId" property to reserved identifier should fail gracefully

GitHub Issuen/a
TypeImprovement
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2017-05-19T14:14:19.000+0000
Affected Version/sn/a
Fix Version/sRelease 6.2.0
ComponentsiOS
Labelsn/a
ReporterHans Knöchel
AssigneeHans Knöchel
Created2017-03-27T20:52:25.000+0000
Updated2017-05-19T14:16:47.000+0000

Description

There are properties like "badge" and "constants" that are private API of the 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 "" is reserved by the system, please choose a different name and try again.". Easy one.

Comments

  1. Hans Knöchel 2017-03-27

    PR: https://github.com/appcelerator/titanium_mobile/pull/8912
  2. Vijay Singh 2017-04-05

    [~hansknoechel] Can you give a Test Case ?
  3. Hans Knöchel 2017-04-05

    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 badge and set a text to 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.
  4. Vijay Singh 2017-04-11

    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();
       
  5. Harry Bryant 2017-05-19

    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.*

JSON Source