Uploaded image for project: 'Appcelerator - INBOX'
  1. Appcelerator - INBOX
  2. AC-3027

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

    Details

      Description

      Problem

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

      IOS Error

      [ERROR] Value was not the value expected. ([rows containsObject:row]) was not (YES) in -[TiUITableView deleteRow:] (TiUITableView.m:524
      2012-02-21 09:16:02.692 TestListBox[2189:17903] *** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit-1912.3/UITableView.m:1046
      [ERROR] The application has crashed with an unhandled exception. Stack trace:
      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

      Steps to reproduce

      1. Make a project with the below app.js.
      2. Click the 'update rows' button (this will only update row 0)
      3. 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)

      app.js

      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();
      

        Attachments

          Activity

            People

            • Assignee:
              mpmiranda Mauro Parra-Miranda
              Reporter:
              jlbarnhart Jon Barnhart
            • Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Git Source Code