Nothing prints out in the console in command line tool Xcode

前端 未结 1 544
天涯浪人
天涯浪人 2020-12-22 04:28

Nothing prints out in the console in command line tool Xcode when I run the following code:

import Foundation

class A {
  var someValue = 0

  let concurren         


        
相关标签:
1条回答
  • 2020-12-22 05:21

    Applications – such has command-line programs – which do not already have a "run loop" have to call

    dispatch_main() // Swift 2
    dispatchMain()  // Swift 3
    

    in order to use GCD. From the documentation:

    This function "parks" the main thread and waits for blocks to be submitted to the main queue. Applications that call UIApplicationMain (iOS), NSApplicationMain (Mac OS X), or CFRunLoopRun on the main thread must not call dispatch_main.

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