My code was working perfectly in before.. recently i have installed Alamofire in other project now below error throwing.
Pattern cannot ma
Error is related to a small mistake(i.e .success syntax according to Alomofire, and change AF as Alamofire), I have correct the Syntax as well as code. Now you can use as follows:-
func postImageRequestWithURL(withUrl strURL: String,withParam postParam: Dictionary,withImages imageArray:NSMutableArray,completion:@escaping (_ isSuccess: Bool, _ response:NSDictionary) -> Void) {
Alamofire.upload(multipartFormData: { (MultipartFormData) in
// Here is your Image Array
for (imageDic) in imageArray {
let imageDic = imageDic as! NSDictionary
for (key,valus) in imageDic {
MultipartFormData.append(valus as! Data, withName:key as! String,fileName: "file.jpg", mimeType: "image/jpg")
}
}
for (key, value) in postParam {
MultipartFormData.append((value as AnyObject).data(using: String.Encoding.utf8.rawValue)!, withName: key)
}
}, usingThreshold: UInt64.init(), to: strURL, method: .post, headers:["userId":"mfjeriefei","key":"cnhsdnchsj"]) {(result) in
switch result {
case .success(let upload, _, _): //........here getting error
upload.uploadProgress(closure: {(progress) in
print("Upload Progress: \(progress.fractionCompleted)")
})
upload.responseJSON { response in
if response.response?.statusCode == 200 {
let json = response.result.value as? NSDictionary
completion(true,json!);
}
else {
let json = response.result.value as? NSDictionary
completion(false,json!);
}
}
case .failure(let encodingError)://............here getting error
print(encodingError)
completion(false,[:]);
}
}
}