Created
May 13, 2015 04:27
-
-
Save hankbao/78a6bd30bd5a7ac0470b to your computer and use it in GitHub Desktop.
call() and get a stack overflow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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