NSJSONSerialization not working as expected in a Playground

后端 未结 1 1731
遥遥无期
遥遥无期 2020-12-21 15:34

I have to get football game schedule via JSON and extract date of each game of one of the specific universities.

I tried:

let url = NSURL(string: \"S         


        
1条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-21 16:07

    In order to use asynchronous operations in an Xcode Playground, you need to set needsIndefiniteExecution to true.

    Add this at the top of your code:

    Swift 2

    import XCPlayground
    XCPlaygroundPage.currentPage.needsIndefiniteExecution = true
    

    Swift 3

    import PlaygroundSupport
    PlaygroundPage.current.needsIndefiniteExecution = true
    

    0 讨论(0)
提交回复
热议问题