I'm trying to make an async request inside XCode 7.3 playground, using Alamofire. I've included two additional statements - needsIndefiniteExecution = true
and finishExecution()
as described in this answer: https://stackoverflow.com/a/33536290/603268.
import Foundation
import Alamofire
import XCPlayground
XCPlaygroundPage.currentPage.needsIndefiniteExecution = true
print("Before request")
Alamofire
.request(.GET, "http://jsonplaceholder.typicode.com/users")
.responseString { res in
print(res)
XCPlaygroundPage.currentPage.finishExecution()
}
//.resume() - adding this did not help
I've also set the playground execution mode to manual.
The first time, everything works fine, the response is printed and the playground finishes execution.
However, if I run it second time, it hangs and does not print any output (even no "Begin request"). I have to restart XCode to make it work again.