NSAssertionFailure upon launch with view based table, core data and bindings
| Originator: | armadsen | ||
| Number: | rdar://10633569 | Date Originated: | 12/31/2011 |
| Status: | Open | Resolved: | |
| Product: | Mac OS X SDK | Product Version: | 10.7.2 (11C74) |
| Classification: | Serious Bug | Reproducible: | Always |
In an app using a view based NSTableView with an NSArrayController set to entity mode, and a sort descriptors binding, the following assertion failure message is logged and an exception is thrown upon loading a previously-saved Core Data persistent store file:
SortDescriptorsBug[59053:407] *** Assertion failure in -[NSTableRowData _addRowViewForVisibleRow:withPriorView:], /SourceCache/AppKit/AppKit-1138.23/TableView.subproj/NSTableRowData.m:2479
SortDescriptorsBug[59053:407] Row 1 should be in the valid visible section
Steps to Reproduce:
1. Create a new non-document-based, Core Data application via Xcode's project templates (using ARC).
2. In the core data model define a single entity with a single string attribute.
3. In the App Delegate, define a read-only property "sortDescriptors" which simply returns an array with a single ascending sort descriptor with a key matching the name of one of the string property of the entity.
4. In MainMenu.xib, add an NSArrayController set to entity name mode with an entity name matching the entity defined in the model. Enable "Avoid Empty Selection", "Preserve Selection", "Select Inserted Objects", "Clear Filter Predicate On Insert", "Auto Rearrange Content, "Prepares Content", and "Editable. Notably, do *not* enable "Uses Lazy Fetching".
5. Add a view-based NSTableView with a single column and two text fields, one for each string property to the main window.
6. Bind the array controller's managedObjectContext binding to the app delegate's managedObjectContext property, and its sortDescriptors binding to the app delegates sortDescriptors property.
7. Add Add and Remove buttons to the menu, connected to the array controller's add: and remove: methods.
8. Open the app, click Add three or four times to create some entries in the table.
9. Quit the app, which will save the managedObjectContext.
10. Reopen the app.
Expected Results:
The app reopens, redisplaying the entries added in step 7 with no errors.
Actual Results:
The following two messages are logged, and an an exception is thrown:
SortDescriptorsBug[59171:407] *** Assertion failure in -[NSTableRowData _addRowViewForVisibleRow:withPriorView:], /SourceCache/AppKit/AppKit-1138.23/TableView.subproj/NSTableRowData.m:2479
SortDescriptorsBug[59171:407] Row 1 should be in the valid visible section
0 CoreFoundation 0x00007fff8f73b286 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff84928d5e objc_exception_throw + 43
2 CoreFoundation 0x00007fff8f73b0ba +[NSException raise:format:arguments:] + 106
3 Foundation 0x00007fff8ce597d3 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 169
4 AppKit 0x00007fff8a4f7af3 -[NSTableRowData _addRowViewForVisibleRow:withPriorView:] + 164
5 AppKit 0x00007fff8a4f79e2 -[NSTableRowData _addRowViewForVisibleRow:withPriorRowIndex:inDictionary:withRowAnimation:] + 184
6 AppKit 0x00007fff8a4f7928 -[NSTableRowData _addRowViewForVisibleRow:] + 38
7 AppKit 0x00007fff8a4f706c -[NSTableRowData _unsafeUpdateVisibleRowEntries] + 448
8 AppKit 0x00007fff8a4f6e87 -[NSTableRowData updateVisibleRowViews] + 95
9 AppKit 0x00007fff8a48ec56 -[NSTableView viewWillDraw] + 156
10 AppKit 0x00007fff8a3f1c11 -[NSView viewWillDraw] + 666
11 AppKit 0x00007fff8a3f1c11 -[NSView viewWillDraw] + 666
12 AppKit 0x00007fff8a3f24a2 -[NSScrollView viewWillDraw] + 43
13 AppKit 0x00007fff8a3f1c11 -[NSView viewWillDraw] + 666
14 AppKit 0x00007fff8a3f1c11 -[NSView viewWillDraw] + 666
15 AppKit 0x00007fff8a3f0952 -[NSView _sendViewWillDrawInRect:clipRootView:suppressRecursion:] + 1358
16 AppKit 0x00007fff8a3ef6c1 -[NSView displayIfNeeded] + 1039
17 AppKit 0x00007fff8a3ef07d _handleWindowNeedsDisplayOrLayoutOrUpdateConstraints + 648
18 Foundation 0x00007fff8cde6014 __NSFireTimer + 102
19 CoreFoundation 0x00007fff8f6eff84 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
20 CoreFoundation 0x00007fff8f6efad6 __CFRunLoopDoTimer + 534
21 CoreFoundation 0x00007fff8f6d0471 __CFRunLoopRun + 1617
22 CoreFoundation 0x00007fff8f6cfae6 CFRunLoopRunSpecific + 230
23 HIToolbox 0x00007fff85cb23d3 RunCurrentEventLoopInMode + 277
24 HIToolbox 0x00007fff85cb963d ReceiveNextEventCommon + 355
25 HIToolbox 0x00007fff85cb94ca BlockUntilNextEventMatchingListInMode + 62
26 AppKit 0x00007fff8a3b33f1 _DPSNextEvent + 659
27 AppKit 0x00007fff8a3b2cf5 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 135
28 AppKit 0x00007fff8a3af62d -[NSApplication run] + 470
29 AppKit 0x00007fff8a62e80c NSApplicationMain + 867
30 SortDescriptorsBug 0x0000000100001802 main + 34
31 SortDescriptorsBug 0x00000001000017d4 start + 52
32 ??? 0x0000000000000003 0x0 + 3
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!
I think you're triggering a reload of the table 'too early'
I've blogged what I've found out about this issue here: http://orangejuiceliberationfront.com/view-based-nstableviews-row-1-should-be-in-the-valid-visible-section/