"Reading notes" iOS network-rule of thumb for error handling

Source: Internet
Author: User

One, the error is handled in the interface contract.

Second, the error state may be incorrect.

The device is ambiguous to confirm that the operation is a cult failure. For example, a mobile app makes an HTTP request to transfer funds between two accounts. The request was received by the banking system and processed correctly; However, the Nsurlconnection report timed out because the network failure response was lost. The timeout occurred, but it happened after the transfer request was successful. If you retry the operation, it will result in a duplicate transfer, which may cause the user to overdraw.

Third, verify the load.

JSON and XML have a payload format for the validation mechanism, but the comma-separated value file and HTML do not have this mechanism.

Four, the separation of errors and normal business conditions.

Five, always check HTTP status.

Six, always check the value of Nserror.

Seven, use a consistent method to handle errors.

Eight, always set the time-out.

In iOS, the default supermarket time for HTTP requests is 4 points, which is too long for mobile apps. Most users will not wait 4 minutes in any app. Developers need to choose a reasonable time-out, in the way

Evaluate the possible response times for network requests, and then take into account the network latency under the worst-case network scenario.

Reference: "iOS network advanced programming-iphone and ipad Enterprise application Development"

"Reading notes" iOS network-rule of thumb for error handling

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.