Objection The reference problem of the unified management object, I think this is the meaning of this technology.
Don't talk nonsense, let's go straight to the steps:
1: protocol
It is our consciousness to know that everything revolves around agreements.
The following protocol is a view of the Protocol, the Protocol is simply no longer easy.
It does not expose any variables and interfaces, just to refer to the view corresponding to the protocol.
I tend to write a protocol separately into a file.
Then, all the protocols are referenced in the same file.
Finally, put the file in the PCH as a global file.
The principle that follows is that the protocol is shared.
2: Class implementation for protocol correspondence
In this example is a view, of course, to follow the protocol.
3: Class for registration protocol
Objection since the object is to solve the reference problem, then through the protocol, it wants to register the object in.
How to do it?
3.1:objection is implemented through Jsobjectionmodule.
@interface searchviewctrlmodule:jsobjectionmodule @end @implementation searchviewctrlmodule-(void) Configure {
3.2: Add into objection:
Jsobjectioninjector *injector = [Jsobjection defaultinjector];injector = injector? : [Jsobjection createinjector];injector = [injector Withmodule:[[searchviewctrlmodule alloc] init]]; [Jsobjection Setdefaultinjector:injector];
4: Use
Jsobjectioninjector *injector = [Jsobjection defaultinjector]; Uiviewcontroller <SearchViewCtrlProtocol> *VC = [Injector getObject: @protocol (Searchviewctrlprotocol)];
Oc-objection one of the learning notes: a simple start