Background threads consuming 100% CPU on iPhone 3GS causes latent main thread

前端 未结 3 442
悲哀的现实
悲哀的现实 2020-12-30 09:48

In my application I am executing 10 asynchronous NSURLConnections within an NSOperationQueue as NSInvocationOperations. In order to prevent each operation from returning be

3条回答
  •  误落风尘
    2020-12-30 10:23

    James, although I haven't experienced your problem, what I've had success with is using the synchronous connection for downloading within an NSOperation subclass.

    NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&requestError];
    

    I use this approach for grabbing image assets from network locations and updating the target UIImageViews. The download occurs in NSOperationQueue and the method that updates the image-view is performed on the main thread.

提交回复
热议问题