i have some problem with generic type. I want to check if generic type conform some protocol and after pass to another generic function. For example i have function:
func requestSignal<T:Mappable>(target:Api) -> SignalProducer<[T], NSError>
And i want to do something like this:
func request<T>(target:Api, withObjectType type: T.Type) {
if let mappableType = type as? Mappable.Type {
let requestSignal: SignalProducer<[?????], NSError> = self.requestSignal(target) }
But if i tried pass T - it doesn't conform Mappable.
if pass mappableType - it is not a type
您可以将T定义为Mappable,就像在第一个函数中一样。
func request<T: Mappable>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.