lundi 30 mai 2016

Swift Mirror API - Which protocols an object conforms to

Is there a Swift Mirror API call that can tell me what protocols an object conforms to, ie:

protocol ProtocolA {}
protocol ProtocolB {}
protocol ProtocolC {}

class User : A, C {}

Then if I had the following code, it would print out A & C

let u = User()
let mirror = Mirror(reflecting: u)
let protocols = mirror.whichProtocols() // Made up code
print(protocols) //A & C





Aucun commentaire:

Enregistrer un commentaire