iOS Concurrency with GCD and Operations - Part 8: | Ray Wenderlich

Hi, are there a certain recommendations on how many operations a person should create for their app? Appleā€™s website mentions not spawning too many operations because the overhead caused by dispatching is high, and Iā€™m wondering if thereā€™s a number to work with or some kind of rule to go by; such as maybe one that might be based off the standard number of cores used in the average device. With that in mind, do you think it would be a bad idea if we were to only use one operation to perform multiple tasks as opposed to 3 or 4?
Great material by the way.
Thanks

hi! Iā€™m not aware of any advice on this ā€” maybe just trial and error on real devices? itā€™s true you wonā€™t get more really-concurrent processes than the number of cores. As for multiple tasks per operation: that would probably go against normal modularisation advice. Maybe take advantage of dependencies and QOS settings, to get your operations to run in the best order?

Hi Audry,
I am running XC 11.3.1 for this block
filter.completionBlock = {
self.imageView.image = filter.outputImage
}

I am getting following warning

**2020-03-25 08:57:13.354590-0500 TiltShiftDecompressed[81113:10014239] [Animation] +[UIView setAnimationsEnabled:] being called from a background thread. Performing any operation from a background thread on UIView or a subclass is not supported and may result in unexpected and insidious behavior. trace=(**

thanks Alok! the completionBlock runs off the main queue so I should have dispatched back to main to set the imageView:

filter.completionBlock = {
  DispatchQueue.main.async {
    self.imageView.image = filter.outputImage
  }
}

Iā€™ll fix it in the update.

Attaching a Swift 4.2 Xcode 11 version of exercise files for this lecture, could probably help those who donā€™t have Xcode 10 to be able to run the demo. Did nothing but used the default migration tool, and can verify that the end product works just fine (albeit with 2-3 warnings)
Wonā€™t mind if this is made downloadable directly from the lecture video page - http://f.cl.ly/items/3J0u3x3Z3k080p0O3M40/08_Dependencies.zip

1 Like

@akashlal Please check out the updated version of the course when you get a chance:

https://www.raywenderlich.com/9461083-ios-concurrency-with-gcd-and-operations

I hope it helps!

1 Like