all ids ara unique but still getting error -> 'Fatal: supplied item identifiers are not unique

268 Views Asked by At

im using websocket and DiffableDataSource, when do search i filter my list and show results. if i switch on/off button of a cell and after deleting text and creating table again button app crashes.

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Fatal: supplied identifiers are not unique.' ***

all of my id's are unique but still gettin this error.

enum Section {
    case first
}

struct PairModel {
    let uuid = UUID()
    
    var symbol: String
    var name: String
    var price: Double
    var dailyPercent: Double
    var hasSubscribed: Bool
    var isAd: Bool
    var alertType: String
    var alertDate: String
    var adModel: AdModel?
    var pairId: Int
    var orderNumber: Int
    
    struct AdModel {
        let uuid = UUID()
        let mobileAd: GADNativeAd
    }
    
    
extension PairModel: Hashable {
    static func ==(lhs: PairModel, rhs: PairModel) -> Bool {
        return lhs.uuid == rhs.uuid
    }

    func hash(into hasher: inout Hasher) {
        hasher.combine(uuid)
    }
}

extension PairModel.AdModel: Hashable {
    static func ==(lhs: PairModel.AdModel, rhs: PairModel.AdModel) -> Bool {
        return lhs.uuid == rhs.uuid
    }

    func hash(into hasher: inout Hasher) {
        hasher.combine(uuid)
    }
}
0

There are 0 best solutions below