LXMNetwork
项目介绍
本项目基于 AFNetworking 设计,可以配合 YYModel 和 MJExtension 使用,轻量简洁,功能全面,可实现出参 Model化,错误异常捕获,Mock 本地 JSON。
注意:retry 相关方法将在之后的版本中实现
集成方式
pod 'LXMNetwork'~>0.0.2
使用方法
首先在 AppDelegate 中启动项目组件,然后新建基于 LXMRequest 基类的子类,重写 host、path、method、responseClass 等方法即可。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[[LXMInfoDispatcher shareInstance] setupNetworkDriver];
return YES;
}
response 返回 Model
实现 responseClass
方法
- (Class)responseClass {
return [Model class];
}
返回JSON
设置serialize参数
serialize(NO)
实现协议方法
- (id)customSerialization:(id)JSON error:(NSError **)error {
return JSON;
}