Variable assigned in dispatch block coming back null

后端 未结 2 1978
天涯浪人
天涯浪人 2021-01-27 04:47

I\'m trying to make a network call run in a background thread so it doesn\'t freeze my app while it\'s waiting.

The call happens when I do:

nextTime = [m         


        
2条回答
  •  执笔经年
    2021-01-27 05:07

    Your "outside" NSLog statement should actually go in that inner dispatch_async block that is set to run on the main thread, because that block will execute after you've set the value of nextTime. Any code you place below your asynchronous block call will likely execute way before the code inside the block.

提交回复
热议问题