If an object must absolutely have a delegate set, consider adding the delegate as an input to the object’s initializer and marking its type as forced unwrapped using ! instead of optional via ?. This will force consumers to set the delegate before using the object.
@amanvedsharma Thanks very much for your question!
I imagine they are suggestion to do something like this:
protocol MyDelegate: class {
func doStuff()
}
class MyClass {
weak var delegate: MyDelegate!
init(delegate: MyDelegate){
self.delegate = delegate
}
func myFuction(){
self.delegate.doStuff()
}
}
I hope this helps!
All the best