Protocols and proxies
Protocols and proxies are common in iOS, but there are certainly a lot of people who see him as troublesome, so they don't want to touch him, but you need to know that protocols and proxies will solve some of the problems that iOS can't solve (on its importance).
What are protocols and proxies
The simple point is that the value is passed between pages, when page a jumps to page B (which may come with parameters, this does not affect), or page B returns the data to page A. "Proxy mode (protocol and proxy) is a design
mode, the principle is through a unified pattern, can also be understood as a box inside. A protocol defines a set of methods that are implemented by a class, which is an attribute of a class, usually an instance of another class.
object, can be responsible for completing the original class is not good solution problem ". The agent itself is a property, and the use of proxies is often in line with the protocol. Maybe this class is confusing you, so let's take a look at how we're going to use him, and it's easy for us to understand the real purpose of this pattern.
How to use proxies
Here must mention, we in the practice of how to use him all right, if in the real project, two pages simple jump value also use this agent, to tell the truth, indeed a bit too. defined in page b
A protocol that declares a proxy object. In page A, set yourself as the agent for Page B and complete the proxy method.
When to use a proxy
When an object cannot get a pointer to another object directly, and you want to do something about that variable, you can use proxy mode.
Words do not say much, directly see the case:
ios-protocols and proxies