views:

39

answers:

1

Hello all, I am currently saving images to the iphone's local space whenever I finish loading them. I was wondering if I need a separate thread to do that. I.e

The iphone can be requesting multiple images at the same time and when they are loaded, I call the save to HD method.

Since there are a lot of save to HD method being called at the same time, does anyone think I need a separate thread for each save to hd calls or somekind of queue that stacks the objects before being processed ?

Thanks.

A: 

There is NSOperationQueue class which allows you to run operations in background: http://developer.apple.com/library/ios/#documentation/Cocoa/Reference/NSOperationQueue_class/Reference/Reference.html

See this answer: http://stackoverflow.com/questions/1216304/nsurlconnection-delegation-and-threading-iphone/1216777#1216777

Vladimir Grichina
Thanks for that I just read about it but do you think it is worth doing that ? I.e will I see any performance increase ?
It depends on how do you currently save images. If you save them on main thread, it is likely that it gets locked and app will lag while being used. Especially on actual device (on Simulator it works much faster).
Vladimir Grichina
Am using a bg thread now to do the job then use the main thread to display the image. That seems to better but the image loading is slower is ok as long as it doesn't lock up the UI. Thanks.