Diffable data source crashes on fetching itemIdentifiers

When calling itemIdentifiers(inSection:) on a NSDiffableDataSourceSnapshot, I'm getting different results in Swift 5.1 vs 5.3

Xcode 11.3.1 - Swift 5.1

var snapshot: NSDiffableDataSourceSnapshot<Int, Int> = .init()
let items = snapshot.itemIdentifiers(inSection: 0)
print(items)

// prints empty array []

Xcode 12.3 - Swift 5.3

var snapshot: NSDiffableDataSourceSnapshot<Int, Int> = .init()
let items = snapshot.itemIdentifiers(inSection: 0)
print(items)

// crashes the app with message "Section identifier was not found."

Question

Since itemIdentifiers(inSection:) returns an array and it doesn't throw, shouldn't it always return empty array if the section is not found, instead of crashing? Or am I missing something here?

Terms of Service

Privacy Policy

Cookie Policy