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