ios - Is it possible to hash a Swift protocol? -
i trying write registry in swift maps api's (protocols) implementations (classes). able provide registry api , receive instance of class implements it. in objective-c trivial - call nsstringfromprotocol on protocol , use key dictionary containing classes implement them. in swift, however, not have introspective capability. when try same told myapi.protocol not have member "mirrortype". question how, in swift, without using @objc protocols, can map protocol class implements it. thanks!
by it's not possible without using @objc. solution i've found in case using protocol name (string) key dictionary implementations (in case i'll have 1 instance per protocol).
using @objc force have implementations returning anyobject equivalent (id) in objective-c (if function not return native objective-c type).
hope helps.
Comments
Post a Comment