I found out that if I created a protocol like this:
protocol MyProtocol { } I can't do this:
weak var myVar: MyProtocol? And I found the way to fix this, which is adding @objc to the protocol declaration:
@objc protocol MyProtocol { } But why can this fix the error?
My guess is that adding @objc prevents structs to conform to the protocol, so the value of the variable is gurranteed to be a reference type. Am I right?
Also, adding @objc prevents me from adding swift types like [String: Any]. I also would like to know is there another way of fixing the error.