_ = URLSession.shared.dataTask( with: request ) {
data, response, error in
// ...
}
Assuming this code produces a successful load, data
could be some JSON, or an image, or something else. What is [a way / the best way] to differentiate between different data types on response?
Or, perhaps, is it best to have multiples outlets for URLSession
in one's app that each handle a different Data
type?
Thank you for reading.
This question is not a duplicate of Determine MIME type from NSData? because in order to discover that post, the searcher would be required to: 1. know what a MIME type is; and 2. know what they are for, and therefore use the keyword "MIME" in their search. Although the question posed by this post is answered by the "Determine MIME..." post, its relevance is in providing a searching bridge for people to whom the use of MIME types isn't immediately obvious.