Created
September 19, 2015 02:03
-
-
Save thekarladam/c3974dc545d56b41ee5b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol DelegateOwningType { | |
typealias DelegateType | |
var delegate : DelegateType { get set } | |
} | |
class DelegatedOperation <T : DelegateOwningType, TDelegate where T.DelegateType == TDelegate.Type>: NSOperation { | |
let authority : T | |
var delegate : TDelegate | |
init(someT : T, someTD : TDelegate) { | |
authority = someT | |
delegate = someTD | |
authority.delegate = someTD | |
super.init() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I see, yeah, you wouldn't be able to use ConcreteFoo as the ConcreteDelegateType and satisfy the same-type constraint. You need some way to say "I want an NSNetServiceBrowser with a specific delegate type". You could use a wrapper struct for that:
which I think will work better. That lets this work: