Daily iOS
Memory and ARC

Closure capture and leaks

Which of these two snippets creates a reference cycle?

// (A)
final class VM {
    var onChange: (() -> Void)?
    func bind() { onChange = { self.reload() } }
}
// (B)
final class VC {
    func load() { DispatchQueue.global().async { self.parse() } }
}

Pick one

Submit