devdragonli / protocolservicekit Goto Github PK
View Code? Open in Web Editor NEWiOS组件通信中间件(Protocol Service),Adapter Swift/Objective-C
License: MIT License
iOS组件通信中间件(Protocol Service),Adapter Swift/Objective-C
License: MIT License
通过如下代码多次注册协议实现类时存在隐患,可能产生脏数据:
`
for (int idx = 0; idx < 5; idx++) {
NSArray *clzNameArr = @[@"LFLImp1", @"LFLImp2", @"LFLImp3", @"LFLImp4", @"LFLImp5"];
for (NSString *clzName in clzNameArr) {
[[ProService sharedManger] configProtocolServiceMapsWithDic:@{
@"LFLUnRuleProtocol" : clzName
}];
}
Class clz = ServiceWithProtocol(LFLUnRuleProtocol);
NSLog(@"第%d次注册, 注册类名: %@", idx + 1, NSStringFromClass(clz));
}
`
输出:
2020-11-23 16:23:05.907336+0800 ProtocolServiceManger_Example[63550:522486] 第1次注册, 注册类名: LFLImp2 2020-11-23 16:23:05.907472+0800 ProtocolServiceManger_Example[63550:522486] 第2次注册, 注册类名: LFLImp1 2020-11-23 16:23:05.907584+0800 ProtocolServiceManger_Example[63550:522486] 第3次注册, 注册类名: LFLImp1 2020-11-23 16:23:05.907703+0800 ProtocolServiceManger_Example[63550:522486] 第4次注册, 注册类名: LFLImp3 2020-11-23 16:23:05.907840+0800 ProtocolServiceManger_Example[63550:522486] 第5次注册, 注册类名: LFLImp1 2020-11-23 16:23:05.909481+0800 ProtocolServiceManger_Example[63550:522486] 协议为:LFLUnRuleProtocol,实际实现类为LFLImp4
推荐做线程安全处理。
注册URL的方式,感觉实现路由跳转很简单容易
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.