Commit a1000be6 authored by David黄金龙's avatar David黄金龙

代码优化

parent 165a352f
......@@ -25,8 +25,9 @@ class YHHomeViewController: YHBaseViewController {
initView()
//2.网络请求
requestData()
bind()
requestData()
}
......@@ -44,6 +45,8 @@ class YHHomeViewController: YHBaseViewController {
private func bind() {
homeReqVM.subject.subscribe(onNext: { model in
print("网络请求获取的数据是====>")
print(model)
}).disposed(by: disposeBag)
}
......
......@@ -12,6 +12,7 @@ import RxSwift
class YHHomePageViewModel {
//数据源
var configModel:YHHomeCofigMode?
let subject = PublishSubject<YHHomeCofigMode>()
}
......
......@@ -156,7 +156,7 @@ class YHNetRequest: NSObject {
if statusCode == 200 {
guard let suclock = self.success else { return }
let dittt = self.handleJsonObjectNullValue(serverDict)
suclock(dittt as? [String : Any] ?? ["": ""], statusCode)
suclock(dittt as? [String : Any] ?? [:], statusCode)
} else {
let errorModel = YHNetErrorModel.init()
errorModel.responseErrorType = .failType
......@@ -170,7 +170,7 @@ class YHNetRequest: NSObject {
}
//处理对象为空的情况
func handleJsonObjectNullValue(_ jsonObject: Any) -> Any {
if let jsonArray = jsonObject as? Array<Any> {
let noNullArray: [Any] = jsonArray.map { value in
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment