Chapter 4 : Semaphores Last example what is use of defined queue

I have a question regarding the last example.

let group = DispatchGroup()
let queue = DispatchQueue.global(qos: .userInitiated)

let base = "https://wolverine.raywenderlich.com/books/con/image-from-rawpixel-id-"
let ids = [ 466881, 466910, 466925, 466931, 466978, 467028, 467032, 467042, 467052 ]
var images: [UIImage] = []

for id in ids {
    guard let url = URL(string: "\(base)\(id)-jpeg.jpg") else { continue }
    
    group.enter()
    let task = URLSession.shared.dataTask(with: url) { data, _,error in
        defer { group.leave()}
        
        if error == nil, let data = data, let image = UIImage(data: data) {
            images.append(image)
        }
    }
    
    task.resume()
}

group.notify(queue: queue) {
    let result = images
    result[0]
    PlaygroundPage.current.finishExecution()
}

What is the use of queue here? I don’t see it being used.
URLSession is running in the background queue. the only reason I see it here as notify need the queue in the signature. Otherwise no real use. I am not running anything on it to be notified.

Thanks for reading

You have to tell group.notify(queue:) which queue to send the notification on. The let queue line is there mostly just to make it clear that it’s a dispatch queue. You’d pass in whatever queue you’re working with. In this case, you might even send it to the main queue as you probably are ready to update the UI at that point.

There is a typo in the code block that follows “Wrapping asynchronous methods”, where it starts

queue.dispatch(group: group)

should be

queue.async(group: group)