alamofire

Swift Custom Response Serializer is returning images at random

安稳与你 提交于 2019-12-08 13:20:37
I am currently using Alamofire to Fetch Json data/url-images from a Server. I also created a custom response serializer using this tutorial to convert url images into UIImages upon request. Everything works fine, and I am able to load all of the Images from the server into a UIImageView. The user can then swipe from left to right in order to View each image like a Photo Gallery. The Problem I am having is that my custom response returns the images in a different order. Therefore, every image being displayed is not in the correct order it initially started in. Would anyone know how I can fix

Downloading PDF using NSURLSession (HTTP POST) with parameters

邮差的信 提交于 2019-12-08 13:09:47
问题 I have a problem with downloading PDF file using NSURLSession with POST.My download url is different than any other else because it didn't end with file extension name and it also need parameters to download that file. It's from ASPX base server and return url like that http://example.com/DownloadPDF.aspx?File=ES2Ges%2BUA1CEe1150UF3uUgEDeCEMoIuOrJCbwjzVKCEfA6%2F1zKxycl6MMWcjvtk If I have to access the pdf and download it,I have to provide 2 parameters ConfigKeyID and AccessToken .And one

How to create a NTLM authentication header to use with Alamofire?

血红的双手。 提交于 2019-12-08 13:09:47
问题 These are request headers: let userName = "someUserName" let password = "aPasswordForSomeUserName" var headers: HTTPHeaders = [ "Accept": "application/json", ] if let authorizationHeader = Request.authorizationHeader(user: userName, password: password) { headers[authorizationHeader.key] = authorizationHeader.value } So this is generating Authorization like this. Basic aC5paHFoOkulbXKhNpk43A== (I have modified it for security ). But when I make the same request in Advance Rest Client (a chrome

What is the best way to handle response from Alamofire for a TableView in Swift using separate classes?

我的梦境 提交于 2019-12-08 12:46:33
问题 I'm writing a class to handle my server requests that return JSON to populate a TableView. This is my first time doing this sort of thing, and I was curious what is the be best paradigm to use here. Is something like delegation better than using dispatch_async? Pretty much Alamofire's response is asynchronous, so I can't return data out of it. Since my request is happening in a shared(it exists in a framework I created so I could use it in multiple targets) ServerManager class, I need to get

Alamofire progress callback stops working after returning from background

*爱你&永不变心* 提交于 2019-12-08 10:45:03
问题 I have a method that uploads (video) data to the server, and it looks like this: static func upload(video data:Data, named name:String, parameters:[String:Any], toUrl url:URL, progress:@escaping (Double)->Void, completion:@escaping(Bool)->Void){ manager = Alamofire.SessionManager(configuration: URLSessionConfiguration.background("com.app.backgroundtransfer") manager.upload(multipartFormData: { (multipartFormData) in multipartFormData.append(data, withName: "filedata", fileName: name, mimeType

Realm data Insertion took over 7mins for big size json

孤者浪人 提交于 2019-12-08 08:26:35
问题 I use Alamofire to download big json data which was about around 7MB and use RealmSwift to store data at realmobject and SwiftyJSON to parse.My realm object insertion after it finished download the json seems really slow at insertion.Was something wrong with my bad code?Please guide me. First of all I will show simplest Json : { { "Start" : "40000", "End" : "1000000", "Name" : "Smith", "Address" : "New York" },{...},more than 7000 records... } Here is my AlamofireAPI Protocol import

Ambiguous reference to member 'upload(_:to:method:headers:interceptor:)'

跟風遠走 提交于 2019-12-08 07:51:42
问题 I am uploading an image on button press using Alamofire , but it show an ERROR at AF.upload(multipartFormData: { MultipartFormData line of method (Note : Alamofire.upload is change to AF.upload After Alamofire 5.0 Update) @IBAction func btnUploadImage(_ sender: UIButton) { let uploadDict = ["user_id":getUserId] as [String:String] AF.upload(multipartFormData: { MultipartFormData in let image :Data = UIImageJPEGRepresentation(self.uploadImg.image!, 1.0)! MultipartFormData.append(image, withName

Alamofire API request is getting failed with responseSerializationFailed in swift 3

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-08 07:12:54
问题 I am calling normal API call with Alamofire, And I am not passing any data with that in networking manager class. My Networking class is func executeGetRequest(url:String,requestVC:UIViewController,completionHandler:@escaping (_ responseObject:Any?) -> Void!,failureHandler:@escaping (_ connectionError:NSError?) -> Void!){ //Checking internet alert if !self.isConnectedToInternet(){ // requestVC.showAlert(kText_AppName, message: kText_NoInternet) return } requestVC.showLoader() Alamofire

Alamofire async call [duplicate]

一个人想着一个人 提交于 2019-12-08 06:24:08
问题 This question already has answers here : How to return value from Alamofire (5 answers) Closed 3 years ago . I have a simple problem. I'm connecting to my RESTful server and trying to connect. I do get a response and everything works perfect, however when I try to call a function to set a variable, it just doesn't call it. Code: // // LoginClass.swift // LoginApp // // Created by Tarek Adel on 12/3/16. // Copyright © 2016 Tarek Adel. All rights reserved. // import Foundation import Alamofire;

Add progress to file uploading using Alamofire

折月煮酒 提交于 2019-12-08 05:22:35
问题 How can I get progress of file uploading? // import Alamofire func uploadWithAlamofire() { let image = UIImage(named: "myImage")! // define parameters let parameters = [ "hometown": "yalikavak", "living": "istanbul" ] // Begin upload Alamofire.upload(.POST, "upload_url", // define your headers here headers: ["Authorization": "auth_token"], multipartFormData: { multipartFormData in // import image to request if let imageData = UIImageJPEGRepresentation(image, 1) { multipartFormData