iOS

Networking & URLSession

URLSession, HTTP requests, data tasks, upload, download, error handling, async/await

20 면접 질문·
Mid-Level
1

What is the main difference between URLSession.shared and a custom URLSession instance?

답변

URLSession.shared is a global singleton with default configuration, ideal for simple requests. A custom instance allows configuring behavior (timeouts, caching, delegates) for specific needs. Using a custom instance provides fine-grained control over cache policies, SSL certificates, and redirections.

2

What is the main role of the URLRequest class?

답변

URLRequest encapsulates HTTP request parameters: URL, HTTP method (GET, POST, etc.), custom headers, timeout, request body, and cache policies. It allows precise configuration of how a request should be sent before passing it to URLSession.

3

When to use HTTP POST method instead of GET in a URLRequest?

답변

Use POST to send sensitive data (passwords, tokens), large data volumes, or operations that modify server state. GET is suitable for retrieving data without side effects. POST encapsulates data in the request body, more secure and without size limits.

4

What is the main purpose of adding custom headers to a URLRequest?

5

How to build a complex URL with multiple query parameters using URLComponents?

+17 면접 질문

다음 면접을 위해 iOS을 마스터하세요

모든 질문, flashcards, 기술 테스트, 코드 리뷰 연습, 면접 시뮬레이터에 접근하세요.

무료로 시작하기