What is the primary function of `URLSessionConfiguration`?
iOS interview question for Intermediate practice.
Answer
To define the behavior and policies (caching, timeouts, cookies, etc.) for URLSession tasks.
Explanation
URLSessionConfiguration objects are used to configure the behavior of a URLSession instance and the tasks created within it. You set properties on the configuration object before creating the session to control things like cache policies (urlCache, requestCachePolicy), timeout intervals (timeoutIntervalForRequest, timeoutIntervalForResource), cookie policies (httpCookieStorage, httpCookieAcceptPolicy), default HTTP headers (httpAdditionalHeaders), network service type, TLS settings, and whether to allow cellular access. Parsing JSON (A), constructing URLs (C), and monitoring connectivity (D) are handled by other APIs.