Search code examples
swiftgenericsprotocols

Reference to generic type 'SomeResponse' requires arguments in <...>


I have getting the error "Reference to generic type 'SomeResponse' requires arguments in <...>"

struct SomeResponse<T: Decodable>: Decodable {

     let success: Bool

     let body: T?
}

final class SomeService {

    var response: SomeResponse? ///Reference to generic type 'SomeResponse' requires arguments in <...>

}

I don't fully understand the syntax of what I should write into the property "response"


Solution

  • Your class should also be generic.

    final class SomeService<T: Decodable> {
        var response: SomeResponse<T>?
    }