Titanium JIRA Archive
Appcelerator Community (AC)

[AC-1199] iOS: App crash if bindId is called 'description'

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionDuplicate
Resolution Date2014-10-13T07:22:30.000+0000
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelslistview
ReporterMatej
AssigneeShuo Liang
Created2014-10-04T12:43:55.000+0000
Updated2016-03-08T07:37:34.000+0000

Description

An app will crash if bindId is called description. It would be good to check it out - Why it keep crashing and is it only because of description?
var win = Ti.UI.createWindow({backgroundColor: 'white'});

// Create a custom template that displays an image on the left, 
// then a title next to it with a subtitle below it.
var myTemplate = {
    childTemplates: [
        {                            // Image justified left
            type: 'Ti.UI.ImageView', // Use an image view for the image
            bindId: 'pic',           // Maps to a custom pic property of the item data
            properties: {            // Sets the image view  properties
                width: '50dp', height: '50dp', left: 0
            }
        },
        {                            // Title 
            type: 'Ti.UI.Label',     // Use a label for the title 
            bindId: 'description',          // Maps to a custom info property of the item data
            properties: {            // Sets the label properties
                color: 'black',
                font: { fontFamily:'Arial', fontSize: '20dp', fontWeight:'bold' },
                left: '60dp', top: 0,
            }
        },
        {                            // Subtitle
            type: 'Ti.UI.Label',     // Use a label for the subtitle
            bindId: 'es_info',       // Maps to a custom es_info property of the item data
            properties: {            // Sets the label properties
                color: 'gray',
                font: { fontFamily:'Arial', fontSize: '14dp' },
                left: '60dp', top: '25dp',
            }
        }
    ]
};

var listView = Ti.UI.createListView({
    // Maps myTemplate dictionary to 'template' string
    templates: { 'template': myTemplate },
    // Use 'template', that is, the myTemplate dict created earlier
    // for all items as long as the template property is not defined for an item.
    defaultItemTemplate: 'template'
});
var sections = [];

var fruitSection = Ti.UI.createListSection({ headerTitle: 'Fruits / Frutas'});
var fruitDataSet = [
    // the text property of info maps to the text property of the title label
    // the text property of es_info maps to text property of the subtitle label
    // the image property of pic maps to the image property of the image view
    { description: {text: 'Apple'}, es_info: {text: 'Manzana'}, pic: {image: 'apple.png'}},
    { description: {text: 'Banana'}, es_info: {text: 'Banana'}, pic: {image: 'banana.png'}}
];
fruitSection.setItems(fruitDataSet);
sections.push(fruitSection);

var vegSection = Ti.UI.createListSection({ headerTitle: 'Vegetables / Verduras'});
var vegDataSet = [
    { description: {text: 'Carrot'}, es_info: {text: 'Zanahoria'}, pic: {image: 'carrot.png'}},
    { description: {text: 'Potato'}, es_info: {text: 'Patata'}, pic: {image: 'potato.png'}}
];
vegSection.setItems(vegDataSet);
sections.push(vegSection);

var grainSection = Ti.UI.createListSection({ headerTitle: 'Grains / Granos'});
var grainDataSet = [
    { description: {text: 'Corn'}, es_info: {text: 'Maiz'}, pic: {image: 'corn.png'}},
    { description: {text: 'Rice'}, es_info: {text: 'Arroz'}, pic: {image: 'rice.png'}}
];
grainSection.setItems(grainDataSet);
sections.push(grainSection);

listView.setSections(sections);
win.add(listView);
win.open();
Console output
[ERROR] :  The application has crashed with an uncaught exception 'NSUnknownKeyException'.
[ERROR] :  Reason:
[ERROR] :  [<__NSCFString 0x79751110> valueForUndefinedKey:]: this class is not key value coding-compliant for the key text.
[ERROR] :  Stack trace:
[ERROR] :  
[ERROR] :  0   CoreFoundation                      0x051f8dda __exceptionPreprocess + 154
[ERROR] :  1   libobjc.A.dylib                     0x04dbba97 objc_exception_throw + 44
[ERROR] :  2   CoreFoundation                      0x051f8a11 -[NSException raise] + 17
[ERROR] :  3   Foundation                          0x02312c3a -[NSObject(NSKeyValueCoding) valueForUndefinedKey:] + 282
[ERROR] :  4   Foundation                          0x022553e8 _NSGetUsingKeyValueGetter + 104
[ERROR] :  5   Foundation                          0x02255378 -[NSObject(NSKeyValueCoding) valueForKey:] + 260
[ERROR] :  6   Foundation                          0x0226eb5d -[NSObject(NSKeyValueCoding) valueForKeyPath:] + 383
[ERROR] :  7   Foundation                          0x0226eb1b -[NSObject(NSKeyValueCoding) valueForKeyPath:] + 317
[ERROR] :  8   appName                                 0x002eee8f -[TiUIListItem recordChangeValue:forKeyPath:withBlock:] + 127
[ERROR] :  9   appName                                 0x002ee789 __28-[TiUIListItem setDataItem:]_block_invoke_2 + 281
[ERROR] :  10  CoreFoundation                      0x0512973a __65-[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:]_block_invoke + 106
[ERROR] :  11  CoreFoundation                      0x0512963c -[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 204
[ERROR] :  12  CoreFoundation                      0x05120cc5 -[NSDictionary enumerateKeysAndObjectsUsingBlock:] + 53
[ERROR] :  13  appName                                 0x002ee62c __28-[TiUIListItem setDataItem:]_block_invoke244 + 428
[ERROR] :  14  CoreFoundation                      0x0512973a __65-[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:]_block_invoke + 106
[ERROR] :  15  CoreFoundation                      0x0512963c -[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 204
[ERROR] :  16  CoreFoundation                      0x05120cc5 -[NSDictionary enumerateKeysAndObjectsUsingBlock:] + 53
[ERROR] :  17  appName                                 0x002ed951 -[TiUIListItem setDataItem:] + 2113
[ERROR] :  18  appName                                 0x002ff202 -[TiUIListView tableView:cellForRowAtIndexPath:] + 1714
[ERROR] :  19  UIKit                               0x027bed6c -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 473
[ERROR] :  20  UIKit                               0x027bee4e -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 77
[ERROR] :  21  UIKit                               0x0279867b -[UITableView _updateVisibleCellsNow:isRecursive:] + 3034
[ERROR] :  22  UIKit                               0x027b2f81 -[UITableView layoutSubviews] + 222
[ERROR] :  23  UIKit                               0x027289c0 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 608
[ERROR] :  24  libobjc.A.dylib                     0x04dd1771 -[NSObject performSelector:withObject:] + 70
[ERROR] :  25  QuartzCore                          0x00ed927f -[CALayer layoutSublayers] + 152
[ERROR] :  26  QuartzCore                          0x00ecd105 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 397
[ERROR] :  27  QuartzCore                          0x00eccf60 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
[ERROR] :  28  QuartzCore                          0x00e2b676 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 284
[ERROR] :  29  QuartzCore                          0x00e2ca3c _ZN2CA11Transaction6commitEv + 392
[ERROR] :  30  QuartzCore                          0x00e2d108 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
[ERROR] :  31  CoreFoundation                      0x0511bfbe __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
[ERROR] :  32  CoreFoundation                      0x0511bf00 __CFRunLoopDoObservers + 400
[ERROR] :  33  CoreFoundation                      0x0511193a __CFRunLoopRun + 1226
[ERROR] :  34  CoreFoundation                      0x051111ab CFRunLoopRunSpecific + 443
[ERROR] :  35  CoreFoundation                      0x05110fdb CFRunLoopRunInMode + 123
[ERROR] :  36  GraphicsServices                    0x05c2624f GSEventRunModal + 192
[ERROR] :  37  GraphicsServices                    0x05c2608c GSEventRun + 104
[ERROR] :  38  UIKit                               0x0269de16 UIApplicationMain + 1526
[ERROR] :  39  appName                                 0x0006ce08 main + 456
[ERROR] :  40  libdyld.dylib                       0x057deac9 start + 1
[ERROR] :  
[ERROR] :  2014-10-04 13:40:15.495 appName[35068:18791999] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<__NSCFString 0x79751110> valueForUndefinedKey:]: this class is not key value coding-compliant for the key text.'
[ERROR] :  *** First throw call stack:
[ERROR] :  (
[ERROR] :  	0   CoreFoundation                      0x051f8df6 __exceptionPreprocess + 182
[ERROR] :  	1   libobjc.A.dylib                     0x04dbba97 objc_exception_throw + 44
[ERROR] :  	2   CoreFoundation                      0x051f8a11 -[NSException raise] + 17
[ERROR] :  	3   Foundation                          0x02312c3a -[NSObject(NSKeyValueCoding) valueForUndefinedKey:] + 282
[ERROR] :  	4   Foundation                          0x022553e8 _NSGetUsingKeyValueGetter + 104
[ERROR] :  	5   Foundation                          0x02255378 -[NSObject(NSKeyValueCoding) valueForKey:] + 260
[ERROR] :  	6   Foundation                          0x0226eb5d -[NSObject(NSKeyValueCoding) valueForKeyPath:] + 383
[ERROR] :  	7   Foundation                          0x0226eb1b -[NSObject(NSKeyValueCoding) valueForKeyPath:] + 317
[ERROR] :  	8   appName                                 0x002eee8f -[TiUIListItem recordChangeValue:forKeyPath:withBlock:] + 127
[ERROR] :  	9   appName                                 0x002ee789 __28-[TiUIListItem setDataItem:]_block_invoke_2 + 281
[ERROR] :  	10  CoreFoundation                      0x0512973a __65-[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:]_block_invoke + 106
[ERROR] :  	11  CoreFoundation                      0x0512963c -[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 204
[ERROR] :  	12  CoreFoundation                      0x05120cc5 -[NSDictionary enumerateKeysAndObjectsUsingBlock:] + 53
[ERROR] :  	13  appName                                 0x002ee62c __28-[TiUIListItem setDataItem:]_block_invoke244 + 428
[ERROR] :  	14  CoreFoundation                      0x0512973a __65-[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:]_block_invoke + 106
[ERROR] :  	15  CoreFoundation                      0x0512963c -[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 204
[ERROR] :  	16  CoreFoundation                      0x05120cc5 -[NSDictionary enumerateKeysAndObjectsUsingBlock:] + 53
[ERROR] :  	17  appName                                 0x002ed951 -[TiUIListItem setDataItem:] + 2113
[ERROR] :  	18  appName                                 0x002ff202 -[TiUIListView tableView:cellForRowAtIndexPath:] + 1714
[ERROR] :  	19  UIKit                               0x027bed6c -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 473
[ERROR] :  	20  UIKit                               0x027bee4e -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 77
[ERROR] :  	21  UIKit                               0x0279867b -[UITableView _updateVisibleCellsNow:isRecursive:] + 3034
[ERROR] :  	22  UIKit                               0x027b2f81 -[UITableView layoutSubviews] + 222
[ERROR] :  	23  UIKit                               0x027289c0 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 608
[ERROR] :  	24  libobjc.A.dylib                     0x04dd1771 -[NSObject performSelector:withObject:] + 70
[ERROR] :  	25  QuartzCore                          0x00ed927f -[CALayer layoutSublayers] + 152
[ERROR] :  	26  QuartzCore                          0x00ecd105 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 397
[ERROR] :  	27  QuartzCore                          0x00eccf60 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
[ERROR] :  	28  QuartzCore                          0x00e2b676 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 284
[ERROR] :  	29  QuartzCore                          0x00e2ca3c _ZN2CA11Transaction6commitEv + 392
[ERROR] :  	30  QuartzCore                          0x00e2d108 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
[ERROR] :  	31  CoreFoundation                      0x0511bfbe __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
[ERROR] :  	32  CoreFoundation                      0x0511bf00 __CFRunLoopDoObservers + 400
[ERROR] :  	33  CoreFoundation                      0x0511193a __CFRunLoopRun + 1226
[ERROR] :  	34  CoreFoundation                      0x051111ab CFRunLoopRunSpecific + 443
[ERROR] :  	35  CoreFoundation                      0x05110fdb CFRunLoopRunInMode + 123
[ERROR] :  	36  GraphicsServices                    0x05c2624f GSEventRunModal + 192
[ERROR] :  	37  GraphicsServices                    0x05c2608c GSEventRun + 104
[ERROR] :  	38  UIKit                               0x0269de16 UIApplicationMain + 1526
[ERROR] :  	39  appName                                 0x0006ce08 main + 456
[ERROR] :  	40  libdyld.dylib                       0x057deac9 start + 1
[ERROR] :  )
[ERROR] :  libc++abi.dylib: terminating with uncaught exception of type NSException
-- End simulator log ---------------------------------------------------------

Comments

  1. Shuo Liang 2014-10-13

    Hi, This wiki lists keywords that may not be used as variables, functions, methods, or object identifiers, because either Titanium or another source specifies its usage. [https://wiki.appcelerator.org/display/guides2/Reserved+Words] Regards, Shuo
  2. Shuo Liang 2014-10-13

    Duplicate to [TIDOC-596](https://wiki.appcelerator.org/display/guides2/Reserved+Words)
  3. Matej 2014-10-13

    I see, thank you. My question is then: Shouldn't Titanium/Alloy warn an user about reserved keyword when compiling...?

JSON Source