0
0
iOS Swiftmobile~5 mins

Error handling for network calls in iOS Swift - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the main purpose of error handling in network calls?
To manage problems like no internet, server errors, or bad data so the app can respond gracefully and inform the user.
Click to reveal answer
beginner
Which Swift type is commonly used to represent success or failure in network calls?
The Result type, which has two cases: .success for successful data and .failure for errors.
Click to reveal answer
intermediate
What Swift keyword is used to catch errors thrown during a network call?
The do-catch block is used to try code that can throw errors and handle those errors in the catch section.
Click to reveal answer
intermediate
Why should you check the HTTP status code in a network response?
Because a network call can succeed at the connection level but still return an error status like 404 or 500, which means the request failed.
Click to reveal answer
beginner
What is a common way to inform users about network errors in an iOS app?
Showing an alert or message on screen explaining the problem, like "No internet connection" or "Server unavailable."
Click to reveal answer
Which Swift type helps handle success and failure in network calls?
ADictionary
BResult
CArray
DOptional
What does a 404 HTTP status code mean?
ANot Found
BSuccess
CServer Error
DUnauthorized
Which Swift construct is used to catch errors thrown by functions?
Aswitch
Bguard
Cif-let
Ddo-catch
What should you do if a network call fails due to no internet?
AIgnore the error
BCrash the app
CShow a user-friendly message
DRetry forever without limit
In Swift, how do you represent an error in a Result type?
A.failure
B.success
C.error
D.none
Explain how you would handle errors when making a network call in Swift.
Think about how to catch errors, check response, and show messages.
You got /4 concepts.
    Describe why it is important to check the HTTP status code after a network call.
    Not all network connections that succeed mean the request was successful.
    You got /3 concepts.