iOS4 Implementation of -[NSURLConnection sendAsynchronousRequest:queue:completionHandler:]?

前端 未结 3 485
孤街浪徒
孤街浪徒 2021-01-03 11:40

How can I implement -[NSURLConnection sendAsynchronousRequest:queue:completionHandler:] for iOS < 5?

#if __IPHONE_OS_VERSION_MIN_REQUIRED <         


        
3条回答
  •  感情败类
    2021-01-03 11:47

    I typically make a sub-class of NSOperation and do the sync request inside the main method of the operation. To invoke the operation I create an instance of the sub-class and throw it onto a queue (not the main thread). Then when the operation completes it either calls a delegate with the received data or posts a notification via NSNotificationCenter.

提交回复
热议问题