HTTP Request in swift not working HTTP Request in swift not working swift swift

HTTP Request in swift not working


Try adding this line of code:

URLCache.shared = URLCache(memoryCapacity: 0, diskCapacity: 0, diskPath: nil)


For Swift 3/Xcode 8.2.1, combining a couple of the answers (rv1331, Wouter van Zuilen) gave the best results with no errors in Playground. I'm using this Swift 3 REST example:

http://mrgott.com/swift-programing/30-work-with-rest-api-in-swift-3-and-xcode-8-using-urlsession-and-jsonserialization

import PlaygroundSupportimport FoundationPlaygroundPage.current.needsIndefiniteExecution = trueURLCache.shared = URLCache(memoryCapacity: 0, diskCapacity: 0, diskPath: nil)


Swift 3 code:

<!-- language: lang-c -->import PlaygroundSupportPlaygroundPage.current.needsIndefiniteExecution = true