I am new to objective-c, currently I am writing code that downloads a file from server and then do some operation to the downloaded file. I am confused about dispatch queue and dispatch group.
So I have a function called dowanloadZip, inside this downloadZip function, I am using another function called startHttp to fire the request, but this function is async, I need to wait until the completion block finishes then I can continue checking if the file is complete, do some stuff to it etc. Basically, I need to wait until the completion block finishes then I can continue to do other stuff. My code looks something like this:
-(void)downloadZip:(NSString *url){
...
urlRequest = [reqeustMangaer urlStrig:url]
[requestManager startHttp:urlReuqest completionBlock:^(resposne){
//check response here
}]
}
Someone told me to use dispatch queue, but some other people said to use dispatch group, and I found some code that actually use both. The code I read was using dispatch global queue first, and then inside the queue it's using a dispatch group enter. So should I create a dispatch queue first, then enter the group inside the completion block? Or just use the dispatch group? (I want it to be on background thread). I am also wondering, If I need to call the downloadZip function somewhere else, what should I do?