dispatch_async and block in iOS

后端 未结 3 700
灰色年华
灰色年华 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:43

    The piece of code in

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
    
    });
    

    is run asynchronously on a background thread. This is done because parsing data may be a time consuming task and it could block the main thread which would stop all animations and the application wouldn't be responsive.

    If you want to find out more, read Apple's documentation on Grand Central Dispatch and Dispatch Queue.

提交回复
热议问题