HTTP Request in swift not working

后端 未结 6 963
攒了一身酷
攒了一身酷 2021-02-03 10:19

I\'m trying to learn about working with APIs in Swift. As a good first test, I figured I\'d hit the itunes API and just return some search results. I\'m in playground using the

6条回答
  •  南方客
    南方客 (楼主)
    2021-02-03 11:10

    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 PlaygroundSupport
    import Foundation
    
    PlaygroundPage.current.needsIndefiniteExecution = true
    URLCache.shared = URLCache(memoryCapacity: 0, diskCapacity: 0, diskPath: nil)
    

提交回复
热议问题