Swift Error Message. "Type of expression is ambiguous without more context."

107 Views Asked by At

I keep getting this error message and can't understand why. The object (struct) it is instantiating is and Identifiable struct.

func parseJSON(_ dosageData: Data) -> DoseModel? {
    
    do {
        let json = try JSON(data: dosageData)
        
        let date = json["date"].stringValue
        let medicine = json["medicine"].stringValue
        let units = json["units"].doubleValue
        let value = json["value"].stringValue
        
        let dose = DoseModel(id: UUID(),    --- Error Line ----
                             date: date,
                             medicine: medicine,
                             units: units,
                             value: value)
        
        return dose
        
    } catch {
        delegate?.didFailWithError(error: error)
        return nil
    }
}

Model

struct DoseModel: Identifiable {
    
    var id: ObjectIdentifier
    var date: String
    var medicine: String
    var units: String
    var value: String
  
}
0

There are 0 best solutions below