Skip to content

Instantly share code, notes, and snippets.

@hankbao
Created May 13, 2015 04:27
Show Gist options
  • Save hankbao/78a6bd30bd5a7ac0470b to your computer and use it in GitHub Desktop.
Save hankbao/78a6bd30bd5a7ac0470b to your computer and use it in GitHub Desktop.
call() and get a stack overflow
import Swift
class ClosureStackOverflow {
private var b: Bool = false
private func callClosure1(callback: Void -> Void) {
println("in closure 1")
callback()
}
private func callClosure2(callback: Void -> Void) {
println("in closure 2")
callback()
}
func call() {
callClosure1 { [weak self] in
self?.callClosure2 {
self?.b = true
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment