I'm currently using a dispatch queue to concurrently process and save images taken by the camera in my app.
I need to be able to limit the number of concurrent operations or the app can run out of memory. I know I can set max number of concurrent operations for a NSOperationQueue but I have not been able to find any info regarding dispatch blocks...
I need to be able to limit the number of concurrent operations or the app can run out of memory. I know I can set max number of concurrent operations for a NSOperationQueue but I have not been able to find any info regarding dispatch blocks...
Code:
// the queue I need to limit
imageProcessingQueue = dispatch_queue_create("com.app.imageProcessingQueue", DISPATCH_QUEUE_CONCURRENT);
- (void) saveImage:(UIImage *)image {
dispatch_async(imageProcessingQueue, ^{
// Process the image and save to disk.
dispatch_async(dispatch_get_main_queue(), ^{
// Save the image path and other image info to core data.
});
});
}