Created
February 16, 2019 14:44
-
-
Save amichnia/577f18345fc79d8b28f50f6f97167169 to your computer and use it in GitHub Desktop.
This file contains 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 SomeProtocol { | |
init() | |
} | |
class SomeClass: SomeProtocol { | |
... | |
} | |
// This will work | |
let instance: SomeProtocol = SomeClass.init() | |
// This won't work | |
let instance: SomeProtocol = SomeProtocol.init() | |
// Surprisingly, this also works | |
var type: SomeProtocol.Type! // Expose from Swift | |
type = SomeClass.self // Move it to ObjC! | |
let instance: SomeProtocol = type.init() // Use in Swift |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment