views:

146

answers:

1

Hello guys!

I am doing my download with an object which was inherited from NSOperation. I have read the documentation and when my operation finished I must call the

[self.delegate performSelectorOnMainThread:@selector(operationDidFinish:) withObject:self waitUntilDone:YES];

method. It needs to be called on the main thread, because the UIKit is not thread safe and the documentation says this in these non thread safe frameworks cases. In the delegate method I am drawing a pdf or an image, but because it is drawn on the main thread the User Interface is very laggy until the drawing is finished. Maybe can you suggest me a good way to avoid this problem?

+1  A: 

I am assuming you are downloading image data, decoding it, and rendering the image. The last bit, render, has to happen on the main thread. Can you move the decode part to your download thread? For example, use CGImage calls to decode a png or jpeg, so you have a CGImageRef ready to use before calling operationDidFinish. If you can work with the PDF as images, it would be better to convert it than decode it in the main thread.

drawnonward
Ok, I'll try it.
Infinity