Bird
0
0

What does URLSession.shared represent in Swift?

easy📝 Conceptual Q1 of 15
iOS Swift - Networking
What does URLSession.shared represent in Swift?
AA session that automatically caches all responses
BA custom session that requires manual configuration
CA shared singleton session for basic network tasks
DA session that only handles background downloads
Step-by-Step Solution
Solution:
  1. Step 1: Understand URLSession.shared usage

    URLSession.shared is a built-in singleton instance used for simple network tasks without custom configuration.
  2. Step 2: Compare with other session types

    Custom sessions require configuration, background sessions handle downloads, and caching is optional, so these do not describe shared.
  3. Final Answer:

    A shared singleton session for basic network tasks -> Option C
  4. Quick Check:

    URLSession.shared = shared singleton [OK]
Quick Trick: Use URLSession.shared for quick, simple network calls [OK]
Common Mistakes:
  • Confusing shared with custom configured sessions
  • Assuming shared handles background tasks automatically
  • Thinking shared caches all responses by default

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes