Hello everyone, and readers writing to communicate, to welcome you all to know WisdomRouterKit SDK developers with functionality.
About iOS routing component of the program framework: WisdomRouterKit functionality introduced before have written the book on Jane related articles, but found a lower reading than that, so I decided today to sort out WisdomRouterKit function introduction and use of the program, re-update the next article.
Of course, this issue WisdomRouterKit SDK has added powerful new features.
1: First WisdomRouterKit SDK is a kind of framework?
A: WisdomRouterKit data transfer between the framework and the UIViewController a UIViewController.
Data transfer between two UIViewController in general, we need to create a corresponding type of UIViewController object and then call its read and write the assignment of property,
To complete the data transfer between them, which is the main function of WisdomRouterKit.
Features WisdomRouterKit, without the need for us to manually create the type of UIViewController, data transfer can be completed before the UIViewController jump,
Wherein the transfer support data types include: Model basic data and the model object, as well as closures and UI control object.
2: What kind of projects need to use WisdomRouterKit iOS framework?
A: In general the project, the target can be created by UIViewController class, you can simply transfer the property to achieve.
But if the project is a component-based architecture, in the cross-component calls, we have to reduce the dependencies between functions, property transfer between UIViewController achieve very inconvenient,
At this point if WisdomRouterKit framework to achieve data transfer between the cross-component will be very easy, it can be said as a component of WisdomRouterKit born.
3: WisdomRouterKit SDK in iOS mobile development which can solve our problems, which functions to achieve, what are the advantages?
A: component-based architecture projects, in order to reduce the dependencies between the components to a minimum, we will choose to use a third party framework Router on GitHub.
Currently Router framework on GitHub implementation in two ways:
(1) The first option, with protocol: By registering protocol associated objects, protocol implementation is a good choice, we Protocol Router project is currently in use.
However, the disadvantages of using protocols are obvious, it will make use of the process is to develop a headache. Whenever a property or method changes and adjustments need to re-release a new version of the pods, and update the latest version of this component of the agreement,
There were many places the components interact, how much agreement on the need to target, and registered Association, with the demand iteration, you will find that more and more large protocol library, and no hair thin.
Because without fat weight-loss is not the same functions used in a number of projects led to an agreement can not demand the same version, compatible with the old protocol library needs to function at the same time, to write code for a new repeat function.
(2) A second embodiment, implemented with closures: closures implementations is also a good choice.
Closures implementations disadvantage is also obvious: using a dictionary loading parameters, parameter passing, a function of the expansion is too low, such as multi-pass multiple data model object and closure.
The advantage of WisdomRouterKit, to achieve the above two drawbacks Router scheme is its advantage.
1: a powerful routers iOS SDK, specially handling a data transfer between the components of each module.
2: WisdomRouterKit can help you with your property and closures pass values between pages across components, and supports a set of attributes and closure collection of traditional values, but also get global support Seamless separate objects, without any reference between the various components,
Also you need to define a common protocol for the association between the components, even truly complete solution, truly indomitable spirit.
3: Rapid expansion for future projects or business code overlay function without staff maintenance, no maintenance costs.
4: Advantages of API calls is convenient, flexible, simple to achieve the additional registration call, simply register the number of lines of code, we can expand next Router function.
5: WisdomRouterKit SDK is pure swift to write code to ensure efficient performance of the SDK, support for abnormal data attributes assigned during capture, can help developers quickly locate the problem.
6: OC project little friends do not worry, WisdomRouterKit SDK fully supports OC project calls, although it wants to integrate pod.
Integrated pod: pod ‘WisdomRouterKit’
github link: https: //github.com/tangjianfengVS/WisdomRouterKit
[Basic – pass value]
: no parameter, no closure, simple routing
: There parameters, without closure, simple routing
Note: “testSize” is “SecundViewController” basic attribute name, where the 99.99 assigned to “SecundViewController” of “testSize”.
WisdomRouterParam create the specified double.
: Parameter model object: testModel, simple routing
Note: “testModel” is “SecundThreeViewController” model attribute name, where the testModel assigned to “SecundThreeViewController” of “testModel”.
WisdomRouterParam create the specified model type.
: Parameter model object collection: TestModel collection, simple routing
Note: “testModelList” is “ThreeViewController” model attribute name, where the testModelList assigned to “ThreeViewController” of “testModelList”.
WisdomRouterParam modelList create the specified type.
: closure, simple routing
Note: “closure” is “FourViewController” closure property name, where the hander assigned to “FourViewController” of “closure”.
WisdomRouterHander hander create the specified type.
: WisdomRouterKit Extension
WiseDomrouterKit function extension please see this article: https://www.jianshu.com/p/5d6bd3e0505c
[Advanced Feature – Get Global Single Column]
Global separate Mode need to meet three conditions:
1: Inheritance WisdomRouterModel.
2: Implement a separate statement object.
3: Implement WiseDomrouterShareProtocol and implement the share () method that returns the value as a single column object declared.
Global Single Column TestShaRemodel Get Case:
1: shareName: single Model object name specified component.
2: targetSubstituteClass: acquisition component used as a substitute single Model object class, generally single component Object Model same attribute.
3:! Finally, as strong unpacking Model targetSubstituteClass corresponding type of object generator. If an error or a non-single shareName objects, generates no object attribute value.
According to the above use case, we use WisdomRouterKit, found no success. Because of the need for cross-component UIViewController to register.
3-point register comprises: UIViewController type, and the Mode attribute l UIViewController objects and attributes closure.
Only registered under the type of controller
Sign up here under the controller type and model by model type the name of the associated property registration
Here the register controller type, and the name associated with the closure through a closure property registration
— No model object, without closure
1: @objcMembers modification, retrieves properties when allowed to run.
2: implementation of the registration agreement, including the realization of the agreement method.
3: register through the register method, there is no argument here.
— a model object, a closure
Note: Registered Model: bind by property name and model type.
Registration closure properties: When using (router calls), it will register a callback closures, closures registration and returns the corresponding controller hander property, we only need to determine the type of controller and handerr, forced assignment to unpack it.
Model objects used in WisdomRouterKit, you need to inherit WisdomRouterModel, WisdomRouterModel object has been given a dynamic. After inheriting WisdomRouterModel, Model create yourself also gives dynamic.
【to sum up】
WisdomRouterKit SDK is a reflection of a routing scheme implemented.
As we bring the spirit of convenience, as well as create a project to build components of a bridge in the development, launch WisdomRouterKit SDK, SDK functions will be more perfect late, so stay tuned.
Before we look at the WisdomRouterKit write brief book articles, link: https: //www.jianshu.com/p/5d6bd3e0505c
For technical questions and technical correction, please leave a comment below or add QQ497609288 discussion.