Many Cocoa and CocoaTouch methods have completion callbacks implemented as blocks in Objective-C and Closures in Swift. However, when trying these out in Playground, the co
As of XCode 7.1, XCPSetExecutionShouldContinueIndefinitely() is deprecated. The correct way to do this now is to first request indefinite execution as a property of the current page:
import XCPlayground
XCPlaygroundPage.currentPage.needsIndefiniteExecution = true
…then indicate when execution has finished with:
XCPlaygroundPage.currentPage.finishExecution()
For example:
import Foundation
import XCPlayground
XCPlaygroundPage.currentPage.needsIndefiniteExecution = true
NSURLSession.sharedSession().dataTaskWithURL(NSURL(string: "http://stackoverflow.com")!) {
result in
print("Got result: \(result)")
XCPlaygroundPage.currentPage.finishExecution()
}.resume()