屏幕快照 2018-08-13 下午2.05.44.png
import UIKit
import AFNetworking
enum LEONetWorkRequestType : String {
case GET = "GET"
case POST = "POST"
}
class LEONetWorkTools: AFHTTPSessionManager {
static let shareInstance : LEONetWorkTools = LEONetWorkTools();
}
extension LEONetWorkTools{
func loadNetWorkData(requestType:LEONetWorkRequestType, urlString:String,param:Any,finshBlock:@escaping ((_ finshResult:[String : Any]?,_ error:Error?)->())) {
let successBack = { (task : URLSessionDataTask, result:Any?) in
finshBlock(result as? [String : Any],nil);
};
let filureBack = { (task : URLSessionDataTask?, error:Error) in
finshBlock(nil,error);
};
if requestType == .GET {
get(urlString, parameters: param, progress: nil, success: successBack, failure: filureBack);
}else{
post(urlString, parameters: param, progress: nil, success: successBack, failure: filureBack);
}
}
}
//欢迎加入:洛阳iOS开发交流(570890454)
网友评论