UITableViewDiffableDataSource cannot use struct when Default Actor isolation=Main Actor

import UIKit

struct Song: Hashable, Sendable {
    let id: UUID
    let name: String
}

enum Section: String, Hashable, Sendable {
    case main
}

class ListViewController: UIViewController {
    var dataSource: UITableViewDiffableDataSource<Section, Song>!

    override func viewDidLoad() {
        super.viewDidLoad()
    }
}

error tips: Main actor-isolated conformance of 'Song' to 'Hashable' cannot satisfy conformance requirement for a 'Sendable' type parameter 'ItemIdentifierType'

Xcode26.2, Swift 5, Default Actor isolation=Main Actor

if change Default Actor isolation=nonisolated, is fine.

If you specify nonisolated conformance to Hashable then it works:


struct Song: nonisolated Hashable, Sendable {
    let id: UUID
    let name: String
}

Perfect, thank you for your answer.

1 Like