How To Prevent Memory Leaks In Swift Closures

"Most closure examples that I've seen in tutorials or examples seem to capture self as unowned and call it a day, since capturing self as weak makes it optional, which can be more inconvenient to work with. But as we learned before, this is inherently unsafe since there will be a crash if self is no longer in memory. This isn't much different than just force unwrapping all of your optional variables because you don't want to do the work to safely unwrap them. Unless you can be sure that self will be around as long as your closure is, you should try to capture it weak instead. If you need a non-optional self inside your closure, consider using an if let or guard let to get a strong, non-optional self inside the closure. Because you made this new, strong reference inside the Swift closure, you won't be creating a retain cycle since this reference will be released at the end of the closure."