This is a companion discussion topic for the original entry at https://www.kodeco.com/38462287-ios-concurrency-with-gcd-operations/lessons/19
This is a companion discussion topic for the original entry at https://www.kodeco.com/38462287-ios-concurrency-with-gcd-operations/lessons/19
Hi! Regarding your solution of the challenge, I am wondering why you are not appending the downloaded images using a serial queue so only one operation at a time can modify the array.
shouldn’t be like that since the operation queue for downloading is concurrent?
Your code is:
op.completionBlock = {
if let image = op.image { images.append(image) }
}
and I suppose ideally it should be:
op.completionBlock = {
if let image = op.image {
imagesQueue.addOperation {
images.append(image)
}
}
}
hi Jorge! sorry for the delay. You’re quite right, you should use a serial queue in an app. I should have mentioned it. In a playground, which runs on the main thread, it works without the serial queue.
Thank you for your reply!