if let task = self.caches[identifier] {
failure(["message":"This request is exist, Please wait a moment","code":NSURLErrorCancelled])
return task
}
print("urlString=" + urlString)
if let p = parameters {
FELogDebug("parameters=\(p)")
}
let mesage = NSLocalizedString("translate.1x", comment: "请求链接不能为空!")
assert(!urlString.isEmpty, mesage)
var headers: HTTPHeaders = [
"Accept": "application/json,image/*",
"Cache-Control": "no-cache",
"Content-type": "application/json"
]
headers["User-Agent"] = self.userAgent;
headers["X-DEVICE-ID"] = UIDevice.IDFV;
if let language = feUD.string(forKey: FELanguageKey), !language.isEmpty {
var acceptLanguage = language
if let regionCode = Locale.current.regionCode {
acceptLanguage = "\(language)-\(regionCode)"
}
headers["Accept-Language"] = acceptLanguage
}
if let loginInfo = FELauncher.sharedInstance.getLoginInfo() {
if loginInfo.customerType == .Enterprise {
headers["X-KA-SESSION-ID"] = loginInfo.sessionID
}else if loginInfo.customerType == .Personal {
headers["X-FLE-SESSION-ID"] = loginInfo.sessionID
}
}
let dataRequest = Alamofire.request(urlString,
method: method,
parameters: parameters,
encoding: JSONEncoding.`default`,
headers: headers)
.responseJSON { [weak self](jsonResponse) in
if let statusCode = jsonResponse.response?.statusCode {
if let json = jsonResponse.value {
if statusCode >= 200 && statusCode < 300 {
//successed
success(json)
}else {
//failure
failure(json)
}
}else{
failure(["message":"invalid json"])
}
}else{
if let responseError = jsonResponse.error {
let error = responseError as NSError
print(error)
if error.code != NSURLErrorCancelled {
failure(["message":error.localizedDescription,"code":error.code])
}
}else {
//error
failure(["message":"Request Error!"])
}
}
self?.caches.removeValue(forKey: identifier)
}
if let task = dataRequest.task {
self.caches[identifier] = task
}
return dataRequest.task
}`
it‘s old problem of this crash ,Only occasionally in crash log!And i often receive another crash log “specialized dictionary.subscript.getter” at the same method .Will this be a thread problem?I'm troubled.
Thank you for taking care of this.
If this is still an issue please report a new issue with a crash log. But I recommend updating Alamofire and AlamofireImage, as well as Xcode to see if it still occurs.
Excuse me for bad english!
Alamofire Environment
Alamofire version:4.7.3 Xcode version:11.4 Swift version:4
Project code
http request ` public func FE_Request(with identifier: String, urlString: String, method: HTTPMethod = .get, parameters: Parameters?, success: @escaping ResultHandler, failure: @escaping ResultHandler) -> URLSessionTask? {
it‘s old problem of this crash ,Only occasionally in crash log!And i often receive another crash log “specialized dictionary.subscript.getter” at the same method .Will this be a thread problem?I'm troubled. Thank you for taking care of this.