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

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -