Hi,
I am using a NSOutlineView
with a simple @FetchRequest
containing content:
and detail:
sections. e.g.
NavigationSplitView {
List(tags, selection: $selectedTag) { tag in
NavigationLink(value: tag) {
Text(tag.name ?? "")
}
}
} content: {
if let selectedTag {
let fetchRequest = FetchRequest(fetchRequest: Location.sortedFetchRequest(tag: selectedTag))
AGLocationListView(locations: fetchRequest)
}
else {
Text("Select a Tag")
}
} detail: {
if let selectedTag {
AGMapView(viewModel: AGMapViewModel(tag: selectedTag))
}
}
}
I am inserting a new record using the viewContext on the main thread. in the case when there are no records in the Tag entity I sometimes see the following error:
2023-05-11 22:49:36.388105+1200 Taggy[24576:1000186] [General] NSOutlineView error inserting child indexes <_NSConstantIndexSet: 0x7ff857d84860>[number of indexes: 1 (in 1 ranges), indexes: (1)] in parent 0x0 (which has 0 children).
Then a large stack trace topmost line being:
2 AppKit 0x00007ff818343b6b -[NSOutlineView _validateParentRowEntry:reason:indexes:] + 0
then see:
NSHostingView is being laid out reentrantly while rendering its SwiftUI content. This is not supported and the current layout pass will be skipped.
2023-05-11 22:49:38.376608+1200 Taggy[24576:1000186] [SwiftUI] Publishing changes from within view updates is not allowed, this will cause undefined behavior.
Not sure what I am doing wrong here or if this is an issue with SwiftUI on the Mac with the Split View?
Thanks Ants