Hi!
I'm looping over an array of strings and I need to make a URLRequest call on each element (id).
For each JSON there could be a href linking to other pages with additional data in it.
How can I chain multiple URLRequests?
Currently, in parse(data: data), I check to see if the href key is not null and then I call retrievePages(with url: URL) which is similar to retrieveRelease(). It gets messy. Duplicate code. I get somehow the results I want but I don't think it's the best approach at all.
How could I get the next page of results? Considering that I'm also inside a loop in retrieveRelease()
I'm looping over an array of strings and I need to make a URLRequest call on each element (id).
For each JSON there could be a href linking to other pages with additional data in it.
How can I chain multiple URLRequests?
Currently, in parse(data: data), I check to see if the href key is not null and then I call retrievePages(with url: URL) which is similar to retrieveRelease(). It gets messy. Duplicate code. I get somehow the results I want but I don't think it's the best approach at all.
How could I get the next page of results? Considering that I'm also inside a loop in retrieveRelease()
Code Block func retrieveRelease() { dataTask?.cancel() for id in idArray { idUrl = URL(string: "url+id")! let request = NSMutableURLRequest(url: idUrl) let session = URLSession.shared dataTask = session.dataTask(with: request as URLRequest) { data, response, error in if let error = error as NSError? { return } else if let httpResponse = response as? HTTPURLResponse, httpResponse.statusCode == 200 { if let data = data { self.parse(data: data) DispatchQueue.main.async { //update views } return } } } dataTask?.resume() } } }