dispatch_async and block in iOS

后端 未结 3 695
灰色年华
灰色年华 2020-12-24 11:40

What this piece of code mean?

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        TMBaseParser *parser=[[TMBaseParser al         


        
3条回答
  •  不思量自难忘°
    2020-12-24 12:22

    If the above code snippets doesn't work then, try this:

    Objective-C:

    dispatch_async(dispatch_get_main_queue(), ^{
    
    });
    

    UI updates should always be executed from the main queue. The "^" symbol indicates a start of a block.

    Swift 3:

    DispatchQueue.global(qos: .background).async {
        print("This is run on the background queue")
    
        DispatchQueue.main.async {
            print("This is run on the main queue, after the previous code in outer block")
        }
    }
    

提交回复
热议问题