AFN Two-time package

Source: Internet
Author: User

Create a management singleton class to inherit Afhttpsessionmanager, encapsulate the data request method into the Post method

Urlsession

Substitution of URLConnection in Foundation

Support for network tasks running in the background

Pause/Stop/Restart network tasks, no longer require nsoperation encapsulation

Requests can use the same configuration container

Different session can use different private storage

Block and agent work simultaneously

Upload downloads directly from the file system

Nsurlsessionconfiguration

DEFAULTSESSIONCONFI-Cache/cookie/Certificate Global non-private, approximate to Nsurlconnection

Ephemeralsessionconfiguration-Cache/cookie/Certificate Global private but non-persistent

BACKGROUNDSESSIONCONFI-Suitable for applications being suspended or receiving remote notification

Some properties of nsurlsessionconfiguration

Httpadditionalheaders:http Protocol Header information

Allowcellularaccess/discretionary: The former runs the operator network/the latter is optimized for background network tasks (when a wifi/device is in good condition)

Timeoutintervalforrequest/timeoutintervalforresource: The former resets every time a new data arrives, which limits the length of the entire resource request

Httpmaximumconnectionperhost: Maximum number of concurrent connections for a host

Nsurlsessiontask

can send cancel/resume/suspend messages

Nsurlsessiondatatask return NSData

Nsurlsessiondownloadtask return file, download progress can be resumed

Nsurlsessionuploadtask Upload Nsdata/file/stream

Tasks are suspended by default, remember to send a resume message to a task

AFN Two-time package

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.