Titanium JIRA Archive
Alloy (ALOY)

[ALOY-1110] Another flavor of data binding in Alloy

GitHub Issuen/a
TypeImprovement
Priorityn/a
StatusResolved
ResolutionDuplicate
Resolution Date2014-08-11T15:22:56.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsModels
LabelsTCSupportTriage, api, feature
ReporterDavid He
AssigneeUnknown
Created2014-08-05T07:36:40.000+0000
Updated2018-03-07T22:25:55.000+0000

Description

I have cases where I want to use only one single model for tableView data binding as below - one model for multiple rows...
<Alloy>
	<Model src="adidas"/>
	<Window fullscreen="true" backgroundColor="white">
		<TableView>
			<TableViewRow title="{adidas.name}" />
			<TableViewRow title="{adidas.host_organization}" />
			<TableViewRow title="{adidas.id}" />
		</TableView>
	</Window>
</Alloy>
var adidas = Alloy.Models.instance("adidas");

adidas.fetch({
	"id" : 39
});
$.index.open();
See the attached screen dump that shows the result I wish to see However, the code snippet above crashes the app probably because such kind of way of data binding has not supported yet in Alloy - see error log
[ERROR] :  The application has crashed with an uncaught exception 'NSInvalidArgumentException'.
[ERROR] :  Reason:
[ERROR] :  -[__NSCFNumber length]: unrecognized selector sent to instance 0xd98c520
[ERROR] :  Stack trace:
[ERROR] :  0   CoreFoundation                      0x042471c8 __exceptionPreprocess + 152
[ERROR] :  1   libobjc.A.dylib                     0x03f038e5 objc_exception_throw + 44
[ERROR] :  2   CoreFoundation                      0x042e4243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
[ERROR] :  3   CoreFoundation                      0x0423750b ___forwarding___ + 1019
[ERROR] :  4   CoreFoundation                      0x042370ee _CF_forwarding_prep_0 + 14
[ERROR] :  5   UIKit                               0x015dae86 -[UILabel _setTextColor:] + 222
[ERROR] :  6   UIKit                               0x015db030 -[UILabel setTextColor:] + 40
[ERROR] :  7   alloyTabView                        0x00154bdb -[TiUITableViewRowProxy configureTitle:] + 347
[ERROR] :  8   alloyTabView                        0x0015814a -[TiUITableViewRowProxy initializeTableViewCell:] + 138
[ERROR] :  9   alloyTabView                        0x000a6f90 -[TiUITableView tableView:cellForRowAtIndexPath:] + 944
[ERROR] :  10  UIKit                               0x0151811f -[UITableView _createPreparedCellForGlobalRow:withIndexPath:] + 412
[ERROR] :  11  UIKit                               0x015181f3 -[UITableView _createPreparedCellForGlobalRow:] + 69
[ERROR] :  12  UIKit                               0x014f9ece -[UITableView _updateVisibleCellsNow:] + 2428
[ERROR] :  13  UIKit                               0x0150e6a5 -[UITableView layoutSubviews] + 213
[ERROR] :  14  UIKit                               0x0148e964 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
[ERROR] :  15  libobjc.A.dylib                     0x03f1582b -[NSObject performSelector:withObject:] + 70
[ERROR] :  16  QuartzCore                          0x0308545a -[CALayer layoutSublayers] + 148
[ERROR] :  17  QuartzCore                          0x03079244 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
[ERROR] :  18  QuartzCore                          0x030790b0 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
[ERROR] :  19  QuartzCore                          0x02fdf7fa _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
[ERROR] :  20  QuartzCore                          0x02fe0b85 _ZN2CA11Transaction6commitEv + 393
[ERROR] :  21  QuartzCore                          0x02fe1258 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
[ERROR] :  22  CoreFoundation                      0x0420f36e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
[ERROR] :  23  CoreFoundation                      0x0420f2bf __CFRunLoopDoObservers + 399
[ERROR] :  24  CoreFoundation                      0x041ed254 __CFRunLoopRun + 1076
[ERROR] :  25  CoreFoundation                      0x041ec9d3 CFRunLoopRunSpecific + 467
[ERROR] :  26  CoreFoundation                      0x041ec7eb CFRunLoopRunInMode + 123
[ERROR] :  27  GraphicsServices                    0x0459c5ee GSEventRunModal + 192
[ERROR] :  28  GraphicsServices                    0x0459c42b GSEventRun + 104
[ERROR] :  29  UIKit                               0x0141ff9b UIApplicationMain + 1225
[ERROR] :  30  alloyTabView                        0x00003d58 main + 456
[ERROR] :  31  libdyld.dylib                       0x04a00725 start + 0
[ERROR] :  2014-08-05 17:34:10.978 alloyTabView[66297:90b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reaso
n: '-[__NSCFNumber length]: unrecognized selector sent to instance 0xd98c520'
[ERROR] :  *** First throw call stack:
[ERROR] :  (
[ERROR] :  	0   CoreFoundation                      0x042471e4 __exceptionPreprocess + 180
[ERROR] :  	1   libobjc.A.dylib                     0x03f038e5 objc_exception_throw + 44
[ERROR] :  	2   CoreFoundation                      0x042e4243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
[ERROR] :  	3   CoreFoundation                      0x0423750b ___forwarding___ + 1019
[ERROR] :  	4   CoreFoundation                      0x042370ee _CF_forwarding_prep_0 + 14
[ERROR] :  	5   UIKit                               0x015dae86 -[UILabel _setTextColor:] + 222
[ERROR] :  	6   UIKit                               0x015db030 -[UILabel setTextColor:] + 40
[ERROR] :  	7   alloyTabView                        0x00154bdb -[TiUITableViewRowProxy configureTitle:] + 347
[ERROR] :  	8   alloyTabView                        0x0015814a -[TiUITableViewRowProxy initializeTableViewCell:] + 138
[ERROR] :  	9   alloyTabView                        0x000a6f90 -[TiUITableView tableView:cellForRowAtIndexPath:] + 944
[ERROR] :  	10  UIKit                               0x0151811f -[UITableView _createPreparedCellForGlobalRow:withIndexPath:] + 412
[ERROR] :  	11  UIKit                               0x015181f3 -[UITableView _createPreparedCellForGlobalRow:] + 69
[ERROR] :  	12  UIKit                               0x014f9ece -[UITableView _updateVisibleCellsNow:] + 2428
[ERROR] :  	13  UIKit                               0x0150e6a5 -[UITableView layoutSubviews] + 213
[ERROR] :  	14  UIKit                               0x0148e964 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
[ERROR] :  	15  libobjc.A.dylib                     0x03f1582b -[NSObject performSelector:withObject:] + 70
[ERROR] :  	16  QuartzCore                          0x0308545a -[CALayer layoutSublayers] + 148
[ERROR] :  	17  QuartzCore                          0x03079244 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
[ERROR] :  	18  QuartzCore                          0x030790b0 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
[ERROR] :  	19  QuartzCore                          0x02fdf7fa _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
[ERROR] :  	20  QuartzCore                          0x02fe0b85 _ZN2CA11Transaction6commitEv + 393
[ERROR] :  	21  QuartzCore                          0x02fe1258 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
[ERROR] :  	22  CoreFoundation                      0x0420f36e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
[ERROR] :  	23  CoreFoundation                      0x0420f2bf __CFRunLoopDoObservers + 399
[ERROR] :  	24  CoreFoundation                      0x041ed254 __CFRunLoopRun + 1076
[ERROR] :  	25  CoreFoundation                      0x041ec9d3 CFRunLoopRunSpecific + 467
[ERROR] :  	26  CoreFoundation                      0x041ec7eb CFRunLoopRunInMode + 123
[ERROR] :  	27  GraphicsServices                    0x0459c5ee GSEventRunModal + 192
[ERROR] :  	28  GraphicsServices                    0x0459c42b GSEventRun + 104
[ERROR] :  	29  UIKit                               0x0141ff9b UIApplicationMain + 1225
[ERROR] :  	30  alloyTabView                        0x00003d58 main + 456
[ERROR] :  	31  libdyld.dylib                       0x04a00725 start + 0
[ERROR] :  )
[ERROR] :  libc++abi.dylib: terminating with uncaught exception of type NSException
-- End simulator log ---------------------------------------------------------
Not sure if binding this way makes sense or not, but it is really useful in my case.

Attachments

FileDateSize
another_flavour_of_binding.png2014-08-05T07:36:40.000+000043570

Comments

  1. Mauro Parra-Miranda 2014-08-06

    Hello [~tlukasavage]! May you please assign to [~jialhe85@gmail.com] (David He) as the original reporter? TIA!
  2. Tim Poulsen 2014-08-11

    Appears to be a duplicate of ALOY-443 (Resolved/Fixed), which will be included in Alloy 1.5.

JSON Source