Use of agents in Swift

Source: Internet
Author: User


1. Define an agreement first.


Protocol httptoolprorocol{    //1. Proxy method to pass the dictionary returned by the server to the caller    func didrecieveresults (result:nsdictionary)}



2. Define a proxy property
    2. Declaring proxy properties    var delegate:httptoolprorocol?


3. Infer whether the proxy implements the proxy method, assuming that the implementation passes the dictionary returned by the server to the caller after deserialization

            3.3.1 returns the data to deserialize            var jsonresult:nsdictionary = nsjsonserialization.jsonobjectwithdata (data, Options: Nsjsonreadingoptions (), Error:nil) as Nsdictionary                        //3.4 pass the dictionary returned by the server to the caller            if (data) {            self.delegate?

. Didrecieveresults (Jsonresult) }


4. Implementing Proxy Methods

  Proxy Method    func didrecieveresults (result:nsdictionary) {    }



Detailed order and OC similar, send this is to just contact Swift children's shoes Some reference, I also just contact Oh, welcome to leave a message, learn together, common progress.



Use of agents in Swift

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.