How do I run Asynchronous callbacks in Playground

前端 未结 8 648
夕颜
夕颜 2020-11-22 11:38

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

8条回答
  •  北海茫月
    2020-11-22 12:05

    The new APIs as for XCode8, Swift3 and iOS 10 are,

    // import the module
    import PlaygroundSupport
    // write this at the beginning
    PlaygroundPage.current.needsIndefiniteExecution = true
    // To finish execution
    PlaygroundPage.current.finishExecution()
    

提交回复
热议问题