What is the best way to call optional delegate functions in Swift?
Suppose that I have the following protocol:
@objc protocol SomeDelegate {
optional func someOptionalFunction(sender: AnyObject)
}
and I have the class that looks like this:
class Foo {
var delegate: SomeDelegate! = nil
func someFunction(email: String, password: String) {
self.delegate.someOptionalFunction?(self)
}
}
Should I call it like this or not? If not, what is the best practice to do it?
Thanks in advance.