Cannot convert value of type StructName<X> to expected argument type 'X'

85 views Asked by At

I am passing a generic Decodable struct with parameter. Here is the struct code ..

struct NameStruct<T: Decodable>: Decodable {
    
  // properties of the struct with property..

    let values: [T]

// coding keys here.
    
} 

Then I am trying pass it like this way into the view..

 func property(NameStruct: T) {
        ImageView.setImage(backdropPath: NameStruct.imageName)
   }

viewModel..

var value: StructName<Struct>? {
        
       
    }

Then I am trying to configure it with dequeueReusableCell function..

        let listValues = viewModel.value
        cell.property(NameStruct: listValues)
        return cell

But I got error ..

Cannot convert value of type 'NameStruct?' to expected argument type 'Struct'..

I am not sure . How can I pass it like generic.

0

There are 0 answers