Dismissing modal view controllers confuses and crashes UITableView

Originator:mail
Number:rdar://17622763 Date Originated:2014-07-10
Status:Open Resolved:
Product:Xcode 6 beta 3 Product Version:iOS 8 beta 3
Classification:Serious Crash Reproducible:Always
 
Summary:
Very basic app:

- Master View Controller with a UITableView
- Master screen has a + button to add new rows
- Tap a row in the Master screen presents the Detail View Controller modally
- Tap the Close button in the Detail screen returns you to the Master screen (through dismissViewController(animated:, completion:)

Steps to Reproduce:
1. Run the attached app. This is based largely on the default Master-Detail Template (using Swift).
2. Press + to add a new row.
3. Tap the row to open the Detail screen.
4. Tap Close on the Detail screen.
5. Press + again.


Expected Results:
A new row is added.

Actual Results:
The app crashes:

*** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit-3262.1/UITableView.m:1581
*** 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 (2) must be equal to the number of rows contained in that section before the update (2), plus or minus the number of rows inserted or deleted from that section (1 inserted, 0 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).'

NOTE: Tapping + without going to the Details screen works fine. You can tap it as many times as you want. But when you go to the Details screen and come back, tapping + is broken. The Details screen does not have any functionality in it,

Version:
Xcode 6 beta 3

Notes:


Configuration:
Any of the simulators on iOS 8. (Haven't tested on device.)

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!