Proxy mode: hand over the work that I need to do (class or struct) to another person with the ability I want (the object that implements the agreement) to execute
Protocol: What capabilities are available
Example: I'm going to buy a train ticket, no time to buy, Commission ox buy a ticket
Agreement: Buy Tickets
: Playground-noun:a place where people can playimport Uikitprotocol buyticketprotocol { //ticket demand---is actually what I need to do
func Buyticket (), Anyobject;} Class myticket{ var delegate:buyticketprotocol?//I do not want to buy, find an agent, as long as the demand to meet the ticket can be func getticket () Anyobject { return delegate!. Buyticket () } }class zhongjie:buyticketprotocol { func buyticket () anyobject { //random return an object C15/>return nsdate () }}let myticket = Myticket () myticket.delegate = Zhongjie () myticket.getticket ()
It is more in the implementation of the Protocol class (employer) delegate Object (proxy) assignment, the implementation way is to pass the delegate class through the page jump to implement the Protocol class, get the agent, to assign value
IOS Proxy Mode DELEGATE