I can see all the Objectives in the list that don’t have a parent, as expected, and I can display all those that have children. However, I encounter an error when attempting to compact anyone with children.
struct ObjectiveTable: View{
@Query(filter: #Predicate<Objective>{$0.parent == nil}) var all : [Objective]
@State var selected : Objective?
var body: some View{
VStack{
List(all ,children: Objective.sonsNIL){ line in
Text(line.name)
}
}
}
}
@Model
final class Objective{
@Attribute(.unique)
var id = UUID()
var name: String
var parent: Objective? = nil
@Relationship(deleteRule: .cascade, inverse: Objective.parent)
var sons: [Objective] = []
var sonsNIL: [Objective]?{
get{
if sons.count < 1{
return nil
} else{
return sons
}
}
}
...
Row index -1 out of row range (numberOfRows: 9) for <SwiftUI.SwiftUIOutlineListView: 0x112087000>
(
0 CoreFoundation 0x000000018c834ec0 __exceptionPreprocess + 176
1 libobjc.A.dylib 0x000000018c31acd8 objc_exception_throw + 88
2 AppKit 0x00000001903eb304 -[NSTableRowData _availableRowViewWhileUpdatingAtRow:] + 0
3 SwiftUI 0x00000001bb365224 $s7SwiftUI0A17UIOutlineListViewC11removeItems2at8inParent13withAnimationy10Foundation8IndexSetV_ypSgSo07NSTableeL7OptionsVtF + 1388
4 SwiftUI 0x00000001bb3656f8 $s7SwiftUI0A17UIOutlineListViewC11removeItems2at8inParent13withAnimationy10Foundation8IndexSetV_ypSgSo07NSTableeL7OptionsVtFTo + 252
5 CoreFoundation 0x000000018c7a28b4 __invoking___ + 148
6 CoreFoundation 0x000000018c7a272c -[NSInvocation invoke] + 428
7 CoreFoundation 0x000000018c7d7958 -[NSInvocation invokeWithTarget:] + 64
8 AppKit 0x000000019052a110 -[_NSObjectAnimator forwardInvocation:] + 1512
9 CoreFoundation 0x000000018c7a0ee4 ___forwarding___ + 964
10 CoreFoundation 0x000000018c7a0a60 _CF_forwarding_prep_0 + 96
11 SwiftUI 0x00000001bb37e458 $s7SwiftUI22OutlineListCoordinatorC19recursivelyDiffRows_4with2by9expandAllyAA0a9UIOutlineD4ViewC_AA0dC4ItemCAA0nD4TreeVAA14ExpansionStateOtF + 37012
12 SwiftUI 0x00000001bb3802b8 $s7SwiftUI22OutlineListCoordinatorC19recursivelyDiffRows_4with2by9expandAllyAA0a9UIOutlineD4ViewC_AA0dC4ItemCAA0nD4TreeVAA14ExpansionStateOtF + 44788
13 SwiftUI 0x00000001bb37538c $s7SwiftUI22OutlineListCoordinatorC8diffRows2of2toyAA0a9UIOutlineD4ViewC_AA0kD4TreeVtF + 120
14 SwiftUI 0x00000001bb36f3d4 $s7SwiftUI22OutlineListCoordinatorC6update4diff04viewD4Tree18idSelectionChanged010navigationk4SeedL0011templateRowL011transactionySb_AA04ViewdI0VS3bAA11TransactionVtFyycfU_yyXEfU_ + 220
15 SwiftUI 0x00000001bb369044 $s7SwiftUI22OutlineListCoordinatorC24withSelectionUpdateGuard33_BE7B171B0BEE2A9E27ED12968C3771F8LLyySS_yyXEtF + 1320
16 SwiftUI 0x00000001bb36f2d4 $s7SwiftUI22OutlineListCoordinatorC6update4diff04viewD4Tree18idSelectionChanged010navigationk4SeedL0011templateRowL011transactionySb_AA04ViewdI0VS3bAA11TransactionVtFyycfU_ + 708
17 SwiftUICore 0x00000002277cb578 $sIeg_ytIegr_TRTA + 28
18 SwiftUICore 0x0000000227a6d2b8 $s7SwiftUI6UpdateO15dispatchActionsyyFZ + 1236
19 SwiftUICore 0x0000000227a6c79c $s7SwiftUI6UpdateO3endyyFZ + 212
20 SwiftUICore 0x0000000227f6061c $sSo9NSRunLoopC7SwiftUIE11addObserveryyyycFZySo05CFRunbF3RefaSg_So0gB8ActivityVSvSgtcfU_Tf4ddd_n + 176
21 CoreFoundation 0x000000018c7c17a8 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 36
22 CoreFoundation 0x000000018c7c1694 __CFRunLoopDoObservers + 552
23 CoreFoundation 0x000000018c7c0380 CFRunLoopRunSpecific + 648
24 HIToolbox 0x0000000197c000cc RunCurrentEventLoopInMode + 292
25 HIToolbox 0x0000000197c05d1c ReceiveNextEventCommon + 220
26 HIToolbox 0x0000000197c06020 _BlockUntilNextEventMatchingListInModeWithFilter + 76
27 AppKit 0x0000000190303650 _DPSNextEvent + 660
28 AppKit 0x0000000190c2a408 -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 688
29 AppKit 0x00000001902f675c -[NSApplication run] + 480
30 AppKit 0x00000001902cd02c NSApplicationMain + 888
31 SwiftUI 0x00000001ba77045c $s7SwiftUI6runAppys5NeverOSo21NSApplicationDelegate_So11NSResponderCXcFTf4e_nAA07TestingdG0C_Tg5Tm + 160
32 SwiftUI 0x00000001babf4854 $s7SwiftUI6runAppys5NeverOxAA0D0RzlF + 84
33 SwiftUI 0x00000001baf04134 $s7SwiftUI3AppPAAE4mainyyFZ + 224
34 Marlo SystemManagement.debug.dylib 0x0000000104c5e108 $s22Marlo_SystemManagement0a1_bC3AppV5$mainyyFZ + 40
35 Marlo SystemManagement.debug.dylib 0x0000000104c5e1d4 __debug_main_executable_dylib_entry_point + 12
36 dyld 0x000000018c358274 start + 2840
)
FAULT: NSTableViewException: Row index -1 out of row range (numberOfRows: 9) for <SwiftUI.SwiftUIOutlineListView: 0x112087000>; (user info absent)`
New contributor