Objective-C Blocks and variable scope

后端 未结 2 733
北荒
北荒 2020-12-21 09:03

I would like to set the value of an NSData object within my block. Can someone let me know what I have done wrong here?

// Data
__block NSData *         


        
2条回答
  •  死守一世寂寞
    2020-12-21 09:19

    Because the block runs asynchronously, after the rest of your method. Either rewrite your calling code to work with the asynchronous loading, or find a way to perform the block's work synchronously. I don't know what ZSURLConnection is, but check to see if it has a version of the "perform..." method that doesn't run in the background.

提交回复
热议问题