title: Crash while uploading an image using Alamofire
body: <p>This is how I'm trying to upload an image from my phone gallery using Alamofire...</p>
  
  <pre><code>func uploadTheImg() {
      var i = Int()
          i = 0
          for img in imageArray {
              let url = "http://myUrl…"
              let headers = [ "Content-Type":"application/x-www-form-urlencoded"]
  
          let imageData: Data = (UIImageJPEGRepresentation(img, 0.6) as Data?)!
  
          i = i+1
          let parameters: [String: Any]  =
              [
                  "seller_id": “263”,
                  "is_default": "1",
                  "sequence": "\(i)", //This specifies the no.of images picked from the phone gallery
                  "image": imageData // This is each of the image in the array.
                  "access_token": “4c10c1f41e2cfddb146fd54e871890e2”,
          ]
          Alamofire.upload(multipartFormData: {(multipartFormData) in
              let filePath = NSURL(fileURLWithPath: url)
  
              multipartFormData.append(imageData, withName: "image", fileName: "\(Date().timeIntervalSince1970).jpeg", mimeType: "image/jpeg")
  
              for (key, value ) in parameters {
                  print(key,value)
                  multipartFormData.append(((value) as AnyObject).data(using: String.Encoding.nonLossyASCII.rawValue)!, withName: key)   //CRASHES HERE
              }
          }, to: url)
          { (result) in
              switch result {
              case .success(let upload, , ):
  
                  upload.uploadProgress(closure: { (progress) in
                      UILabel().text = "\((progress.fractionCompleted * 100)) %"
                      print (progress.fractionCompleted * 100)
                  })
                  upload.responseJSON { response in
  
                      guard ((response.result.value) != nil) else{
                          print(response.result.error!.localizedDescription)
                          return
                      }
                  }
              case .failure(let encodingError):
                  print(encodingError)
                  break
              }}}}
  </code></pre>
  
  <p>But in this part... <code>multipartFormData.append(((value) as AnyObject...</code> the for loop prints the keys and values of the <code>"seller_id","is_default","sequence","image"</code> and then it suddenly crashes without printing the access token. Don't know what is causing this crash...</p>
  
  <p>Any help is appreciated..Thanks...</p>