Just learn how to distribute tasks between threads or send asynchronously. I understand that any operation that βtouchesβ a view must be performed in the main thread. What about: UIImageWriteToSavedPhotosAlbum ? I would suggest that this can be done in the background thread, but am I mistaken?
Also, if you need to do this in the background thread, is there a difference between the two calls below since one saves the UIImage and the other saves the UIImage from the view?
UIImageWriteToSavedPhotosAlbum(_someUIImage ,nil,nil,nil); UIImageWriteToSavedPhotosAlbum(_imageView.image ,nil,nil,nil);
By the way, I use this setting to start the HUD in the main thread and for tasks in the background, this is my intention.
[HUD_code showMessage:@"saving image"]; dispatch_queue_t concurrentQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); dispatch_async(concurrentQueue, ^{ UIImageWriteToSavedPhotosAlbum(someUIImage ,nil,nil,nil); dispatch_async(dispatch_get_main_queue(), ^{ [HUD_code dismiss]; }); });
source share