What is wrong with this code?
self.callback = { self.attempts += 1 self.downloadFailed() }
You cannot assign a value to a closure in this manner.
Use of self inside the closure causes retain cycle.
self
You need to define the type of closure explicitly.
There is nothing wrong with this code. Reference: The Swift Programming Language: Language Guide: Automatic Reference Counting: Strong Reference Cycles for Closures