iOS Development--Network Programming Swift & (iv) asynchronous get mode

Source: Internet
Author: User

Asynchronous Get Mode

1     //MARK:-Asynchronous Get Mode2 func asynchronousget ()3     {4         //Create a Nsurl object5var url:nsurl! = Nsurl (string:"http://m.weather.com.cn/data/101010100.html")6         7         //Create Request Object8var urlrequest:nsurlrequest = nsurlrequest (Url:url, CachePolicy:NSURLRequestCachePolicy.UseProtocolCachePolicy, timeOutInterval:Ten)9         Ten         //connecting to a server Onevar connection = Nsurlconnection (Request:urlrequest,Delegate: Self) A     } -      -      the     //MARK:-nsurlconnectiondelegate:nsobjectprotocol { - func Connection (connection:nsurlconnection, Didfailwitherror error:nserror) -     { -         //request failed +     } -Func Connectionshouldusecredentialstorage (connection:nsurlconnection)Bool +     { A         //connection should use certificate store at         return true -     } - func Connection (connection:nsurlconnection, Willsendrequestforauthenticationchallenge Challenge: Nsurlauthenticationchallenge) -     { -         //Send Request Verification -     } inFunc connection (connection:nsurlconnection, Canauthenticateagainstprotectionspace protectionspace: Nsurlprotectionspace)Bool -     { to         //protected space that can be verified +         return true -     } the func Connection (connection:nsurlconnection, Didreceiveauthenticationchallenge Challenge: Nsurlauthenticationchallenge) *     { $         //Get CertifiedPanax Notoginseng     } - func Connection (connection:nsurlconnection, Didcancelauthenticationchallenge Challenge: Nsurlauthenticationchallenge) the     { +         //Cancel Certification A}

iOS Development--Network Programming Swift & (iv) asynchronous get mode

Related Article

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.