Titanium JIRA Archive
Appcelerator Community (AC)

[AC-3027] IOS: Calling Ti.UI.TableView.updateRow causes deleteRow to return [ERROR]

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionFixed
Resolution Date2013-06-13T18:10:45.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
LabelsIOS,, TableView, deleteRow, updaterow
ReporterJon Barnhart
AssigneeMauro Parra-Miranda
Created2012-02-21T07:53:01.000+0000
Updated2016-03-08T07:48:03.000+0000

Description

Problem

When using Ti.UI.TableView.updateRow, you can no longer call Ti.UI.TableView.deleteRow without causing an error.

IOS Error

{panel:borderStyle=dashed| borderColor=#ccc| titleBGColor=#F7D6C1| bgColor=#000000} {color:red}[ERROR] Value was not the value expected. ([rows containsObject:row]) was not (YES) in -[TiUITableView deleteRow:] (TiUITableView.m:524{color} {color:white}2012-02-21 09:16:02.692 TestListBox[2189:17903] *** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit-1912.3/UITableView.m:1046{color} {color:red}[ERROR] The application has crashed with an unhandled exception. Stack trace:{color} {color:white}0 CoreFoundation 0x02e8c052 __exceptionPreprocess + 178 1 libobjc.A.dylib 0x02cacd0a objc_exception_throw + 44 2 CoreFoundation 0x02e34a78 +[NSException raise:format:arguments:] + 136 3 Foundation 0x009752db -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116 4 UIKit 0x00cbf518 -[UITableView(_UITableViewPrivate) _endCellAnimationsWithContext:] + 9000 5 UIKit 0x00cca82a -[UITableView _updateRowsAtIndexPaths:updateAction:withRowAnimation:] + 295 6 UIKit 0x00cca8a5 -[UITableView deleteRowsAtIndexPaths:withRowAnimation:] + 55 7 TestListBox 0x000a1c17 -[TiUITableView dispatchAction:] + 5975 8 TestListBox 0x0009a11c -[TiUITableViewProxy deleteRow:] + 732 9 CoreFoundation 0x02e8de72 -[NSObject performSelector:withObject:] + 66 10 Foundation 0x009049ef __NSThreadPerformPerform + 254 11 CoreFoundation 0x02e6097f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15 12 CoreFoundation 0x02dc3b73 __CFRunLoopDoSources0 + 243 13 CoreFoundation 0x02dc3454 __CFRunLoopRun + 1012 14 CoreFoundation 0x02dc2db4 CFRunLoopRunSpecific + 212 15 CoreFoundation 0x02dc2ccb CFRunLoopRunInMode + 123 16 GraphicsServices 0x02aeb879 GSEventRunModal + 207 17 GraphicsServices 0x02aeb93e GSEventRun + 114 18 UIKit 0x00c3ba9b UIApplicationMain + 1175 19 TestListBox 0x000041ba main + 442 20 TestListBox 0x00002b55 start + 53 21 ??? 0x00000001 0x0 + 1 2012-02-21 09:16:02.792 TestListBox[2189:17903] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (1) must be equal to the number of rows contained in that section before the update (1), plus or minus the number of rows inserted or deleted from that section (0 inserted, 1 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).' *** First throw call stack: (0x2e8c052 0x2cacd0a 0x2e34a78 0x9752db 0xcbf518 0xcca82a 0xcca8a5 0xa1c17 0x9a11c 0x2e8de72 0x9049ef 0x2e6097f 0x2dc3b73 0x2dc3454 0x2dc2db4 0x2dc2ccb 0x2aeb879 0x2aeb93e 0xc3ba9b 0x41ba 0x2b55 0x1) terminate called throwing an exception [INFO] Application has exited from Simulator{color} {panel}

Steps to reproduce

Make a project with the below app.js.

Click the 'update rows' button (this will only update row 0)

Click the 'delete rows' button

#* Notice that the simulator exits with the previous error message. #* - SDK 1.8.2 will not exit but give a similar message. It will only delete row 1 and leave row 0 (the updated one)
var win1 = Ti.UI.createWindow({});


var data = [{title:'Row 1'}, {title:'Row 2'}];
var table = Ti.UI.createTableView({data:data});
win1.add(table);


var btn1 = Ti.UI.createButton({
  title:'delete rows',
  width:120,
  height:50,
  left:10,
  bottom:0
});
btn1.addEventListener('click',DoBtn1Click);
win1.add(btn1);

var btn2 = Ti.UI.createButton({
  title:'update rows',
  width:120,
  height:50,
  right:10,
  bottom:0
});
btn2.addEventListener('click',DoBtn2Click);
win1.add(btn2);


function DoBtn1Click()
{
  for (var row=(table.data[0].rowCount-1); (row >= 0); row--)
    table.deleteRow(row);
}

function DoBtn2Click()
{
  table.updateRow(0, table.data[0].rows[0]);
}

win1.open();

Comments

  1. Mauro Parra-Miranda 2012-02-23

    Hello, tested in 1.9 CI build, it's working fine. You can get the buidl from this page: http://builds.appcelerator.com.s3.amazonaws.com/index.html choose the master branch, and copy the url for your platform, and then from the help menu in Ti Studio, just install from SDK. Best, Mauro
  2. Jon Barnhart 2012-02-23

    Mauro, When I choose the "master" branch, I get the 2.0 SDK downloads. I don't see a choice for 1.9. I did however download the 2.0 SDK and tried it with my test application that I provided in the code and it still gives me the same error. I know that the fix may not be merged into the 2.0 code yet, but is there a way you could merge the fix into 1.8.2? Also, I have simplified the steps to re-create this issue. Jon
  3. Jon Barnhart 2012-03-26

    Verified fix on SDK 2.0.0.v20120325213306. Thanks!

JSON Source