Daily iOS
Networking

Designing a networking layer on URLSession

In a phone screen you're asked to design a simple networking layer in Swift. Without third parties, what types would you put on top of URLSession, and what is each one responsible for?

How would an interviewer hear this answer? You'll see whether they'd move on, dig in, or say no, and which sentences would trip you up. Your score doesn't change.
See the short answer

Three layers are enough: Endpoint (declares path, method, parameters), a generic APIClient (builds the URLRequest, runs it on URLSession, checks the status code, decodes), and a domain error enum. Inject URLSession through a protocol for testing.

Share a question