示例:
1.枚举创建
import UIKit
/// 请求响应状态
///
/// - success: 响应成功
/// - unusual: 响应异常
/// - failure: 请求错误
enum ResponseStatus: Int {
case success = 0
case unusual = 1
case failure = 2
}
class NetworkTools: NSObject {
......
}
2.枚举使用
class CommunityChooseService{
func getCommunityDataList(_ parame_json:Dictionary<String,String>){
NetworkTools.shared.postJSON(APIString: ConfigurationData.getCommunityAPI, false, parameters: request_parameter, needToken: true, needLoading: true) { (state, data, msg) in
//成功
if state.rawValue == ResponseStatus.success.rawValue{
self.delegate?.loadListDataSuccess(data!)
}else if state.rawValue == ResponseStatus.unusual.rawValue{
//响应异常
self.delegate?.loadListDataError(msg!)
}else if state.rawValue == ResponseStatus.failure.rawValue{
//请求错误
self.delegate?.loadListDataError(msg!)
}
}
}
}