The easiest thing to do is use the power of magical optionals.. No if let
or guard
.. since your timer is already an optional, call the method on top of an optional, and everything should be taken care by compiler automatically.
timer?.invalidate()
timer = nil
What it will do is call the method invalidate
if timer
exists.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments