swift - Cast value to Generic Protocol -
i have protocol
public protocol responselistdto: mappable { associatedtype data: mappable var data: [data]! { } }
a once time need cast value protocol, default data type mappable
. try this
if var value = value as? mappable { /// calc code // let value = value as? responselistdto - error if let value = value as? responselistdto, responselistdto.data == mappable { // - error let item in value.data { item.mapping(map: map) } } else { value.mapping(map: map) } }
but have error time.
- protocol 'responselistdto' can used generic constraint because has self or associated type requirements
- associated type 'data' can used concrete type or generic parameter base
how can resolve it?
Comments
Post a Comment