If I use the example code I find in the Quick help for LIST (Creating hierarchical lists) in MAC OS 15.1, I get an error, but not in IOS 18.1. The error happens when I try to Compact any Item I had expanded. If I use a table instead I also get an error, But If I use outline group without list there is not error
struct ContentView: View {
struct FileItem: Hashable, Identifiable, CustomStringConvertible {
var id: Self { self }
var name: String
var children: [FileItem]? = nil
var description: String {
switch children {
case nil:
return "📄 \(name)"
case .some(let children):
return children.isEmpty ? "📂 \(name)" : "📁 \(name)"
}
}
}
let fileHierarchyData: [FileItem] = [
FileItem(name: "users", children:
[FileItem(name: "user1234", children:
[FileItem(name: "Photos", children:
[FileItem(name: "photo001.jpg"),
FileItem(name: "photo002.jpg")]),
FileItem(name: "Movies", children:
[FileItem(name: "movie001.mp4")]),
FileItem(name: "Documents", children: [])
]),
FileItem(name: "newuser", children:
[FileItem(name: "Documents", children: [])
])
]),
FileItem(name: "private", children: nil)
]
var body: some View {
List(fileHierarchyData, children: \.children) { item in
Text(item.description)
}
}
}
Post
Replies
Boosts
Views
Activity
I have a model "Objetive" with recursive iteration. In the user interface I can see all the Items, as expected, and I can expands all those that have children. However, I encounter an error when attempting to compact anyone with children that I have previously expanded, But only when I'm using Mac OS 15.1 On iOS 18.1 Works perfectly.
The error happens in List, Outlinegroup or Table.
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
}
}
}
...
ERROR
Row index -1 out of row range (numberOfRows: 14) for <SwiftUI.SwiftUIOutlineListView: 0x129852200>
(
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 0x0000000100ce6130 $s22Marlo_SystemManagement0a1_bC3AppV5$mainyyFZ + 40
35 Marlo SystemManagement.debug.dylib 0x0000000100ce61fc __debug_main_executable_dylib_entry_point + 12
36 dyld 0x000000018c358274 start + 2840
)
FAULT: NSTableViewException: Row index -1 out of row range (numberOfRows: 14) for <SwiftUI.SwiftUIOutlineListView: 0x129852200>; (user info absent)