Skip to content

Instantly share code, notes, and snippets.

protocol MyProtocol: class {
var sharedInstance: Any? { get set }
}
final class MyProtocolSharedInstanceSetter {
private let myProtocol: MyProtocol
init(myProtocol: MyProtocol, myApi: MyApi) {
self.myProtocol = myProtocol
myApi.getRequest(onCompletion: { [weak self] in myProtocol.sharedInstance = $0 }
}
}
final class DefaultMyProtocol: MyProtocol {
var sharedInstance: Any? = nil
}
protocol MyProtocol {
var sharedInstance: Any?  { get set }
}