Bird
0
0

Which Swift code snippet correctly configures a URLRequest named request to use the POST HTTP method?

easy📝 Syntax Q3 of 15
iOS Swift - Networking
Which Swift code snippet correctly configures a URLRequest named request to use the POST HTTP method?
Arequest.httpMethod = "POST"
Brequest.method = "POST"
Crequest.setMethod("POST")
Drequest.httpVerb = "POST"
Step-by-Step Solution
Solution:
  1. Step 1: Understand URLRequest properties

    The correct property to set the HTTP method is httpMethod.
  2. Step 2: Identify correct syntax

    Assigning "POST" to request.httpMethod correctly sets the method.
  3. Final Answer:

    request.httpMethod = "POST" -> Option A
  4. Quick Check:

    Check for exact property name httpMethod [OK]
Quick Trick: Use request.httpMethod to set HTTP method [OK]
Common Mistakes:
  • Using incorrect property names like 'method' or 'httpVerb'
  • Calling non-existent methods like setMethod()

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes