alamofire

Alamofire 4 error request 'extra argument in call'

浪尽此生 提交于 2019-12-02 11:56:42
I have updated to Xcode8, swift3 and Alamofire 4 and am now getting an error 'extra argument 'method' in call' on the below line beginning 'Alamofire.request' var pulseVoteEndpoint: String = "https://example.com/app1/votingapi/set_votes.json" var pulseNewVote = ["votes":[["value":valueString,"uid":uidString,"entity_id":nidInt,"entity_type":"node","tag":"points","value_type":"points"]]] Alamofire.request(pulseVoteEndpoint, method: .post, parameters: pulseNewVote, encoding: .json) .response { request, response, data, error in debugPrint(response) print(request) print (response) print (error) }

Alamofire Asynchronous requests happening out of order in for loop

安稳与你 提交于 2019-12-02 11:39:44
I'm having this strange issue with Alamofire asynchronous requests in Swift. Here is the pseudocode for what I am trying to do. for each email: GET request to grab first_name for email add first_name to an array The issue is that the end array is out of order. When it should be [User 3, User 1, User 2] it is instead [User 3, User 2, User 1]. I've tested my backend funtions with Postman and everything works so am confused as to what exactly is the problem. Any insight into what might be happening or why I am not getting the correct result. Asynchronous calls are just that. Asynchronous. You

Alamofire multipart upload post error in Swift

喜夏-厌秋 提交于 2019-12-02 11:34:47
When i tried to upload image using Alamofire I'm getting error in .POST Im attaching an image along with this to show the error ( http://www.awesomescreenshot.com/image/422237/0d5fe4a4b486b14fdf52f8ca26d22bea ) I had the same problem , as Michal said it's an installation issue if you are using cocoapods go to your project files/pods/Alamofires/Source and make sure you have 9 files there just like this image and make sure that the MultipartFormData.swift file is there if you are not using cocoapods just open the Alamofire folder and go to source folder and make sure you have the same files

How to send array in params using Alamofire multipart

若如初见. 提交于 2019-12-02 11:02:55
问题 I am using Alamofire for uploading image and file to the server. But I am facing issue to send an array in parameters with the image. But when I send an array in params it converts the array in JSON string. But I want to send an array in params, not JSON string. I have searched a lot and did not find any solution. So please tell me what's wrong in my code. I am using below code: let params = ["id":"112","arrayParam":["1232","12344","14325"]] let url = www.khxjjhdfsj.com/hsdgs let headers:

Alamofire can't access keys of json response

旧城冷巷雨未停 提交于 2019-12-02 10:20:25
I'm new to using Alamofire and have encountered an issue. I'm able to run the following code to print out all the data from an API endpoint. Alamofire.request("http://codewithchris.com/code/afsample.json").responseJSON { response in if let JSON = response.result.value { print(JSON) } } The issue is that when I run this: Alamofire.request("http://codewithchris.com/code/afsample.json").responseJSON { response in if let JSON = response.result.value { print(JSON["firstkey"]) } } I get the error: Type 'Any' has no subscript members I don't know why this error is happening, it seems as if I'm

progress view in alamo fire will not update when downloading file in swift 3

橙三吉。 提交于 2019-12-02 10:01:50
I want to download a file with alamo fire and using alert with progress to show it but the progress will not move when alamo fire progress.fractionCompleted increased I use static var to equal progres.fractionCompleted but it doesn't worked too here is my codes let destination = DownloadRequest.suggestedDownloadDestination() Alamofire.download("example.com", to: destination).downloadProgress(queue: DispatchQueue.global(qos: .utility)) { (progress) in print("Progress: \(progress.fractionCompleted)") sixthLevelViewController.progressdownload = Float(progress.fractionCompleted) DispatchQueue.main

Append object to a variable

谁说胖子不能爱 提交于 2019-12-02 09:41:27
I'm trying to append an object to an array of objects. var products: [Product] = [] init() { Alamofire.request(.GET, Urls.menu).responseJSON { request in if let json = request.result.value { let data = JSON(json) for (_, subJson): (String, JSON) in data { let product = Product(id: subJson["id"].int!, name: subJson["name"].string!, description: subJson["description"].string!, price: subJson["price"].doubleValue) print(product) self.products.append(product) } } } self.products.append(Product(id: 1, name: "test", description: "description", price: 1.0)) print(self.products) } I'm doing a loop

having difficulty fetching JSON Dictionary

孤者浪人 提交于 2019-12-02 09:22:14
My response from API is items are.....****************** ("user_img", http://www.xxx/Content/Images/Products/NoImageAvailable.jpg) items are.....****************** ("user_posts", 10) items are.....****************** ("5", { "post_id" : 135, "post_img" : [ { "guid" : "http:\/\/www.xxx\/wp- content\/uploads\/2016\/10\/IMG_1477393867.jpg" } ] }) items are.....****************** ("9", { "post_id" : 143, "post_img" : [ { "guid" : "http:\/\/www.xxx\/wp-content\/uploads\/2016\/10\/IMG_1477453054.jpg" } ] }) items are.....****************** ("2", { "post_id" : 129, "post_img" : [ { "guid" : "http:\/\

Swift 3 迁移工作总结

和自甴很熟 提交于 2019-12-02 09:08:46
写在前面 Swift 3.0 正式版发布了差不多快一个月了,断断续续的把手上和 Swift 相关的迁移到了Swift 3.0。所以写点小总结。 背景 代码量(4万行) 首先,我是今年年初才开始入手 Swift 的。加上 Swift 的 ABI 和 API 一直不稳定,所以没有在项目中大范围的使用,所以这次迁移的代码量不多,大概在4万行左右。 迁移时间(一天左右) 迁移时间上的话,大概是花了1天左右。两个混编项目,一个 Swift 为主的项目。期中 Swift 为主的项目 花了大概大半天时间,两个混编代码量差不多,但是一个花了小半天,还有一个差不多只花了半个小时(原因先留个悬念~)。 准备 在开发最初开发选择 Swift 的时候的很多决策也让我这次少了很多工作量。 界面用 xib 而不用纯代码 阴差阳错的,和 Swift 相关的大部分界面都是用xib 画的。而这个 xib 在这次迁移中得到了很大的优势,xib 和 SB 的代码不适配 Swift 3。想当初要是使用代码写的 UI 的话,这次迁移改动估计会多很多吧。 关于第三方库的选择: 对于一个项目来说,三方库似乎成了一道必选菜,但是如何去选择这道菜呢? 对于三方库,当初的选择是,能用 OC 就尽量用 OC。 毕竟可以OC 可以无缝衔接到 Swift,而且还相对稳定。 在选择 Swift 相关的三方库时,我尽量值选择使用者比较多的库

How is it possible to perform multiple Alamofire requests that are finished one after another?

不羁的心 提交于 2019-12-02 08:47:49
I would like to perform multiple Alamofire requests. However, because of data dependency a new request should only start when the previous is finished. I already asked a question with a more general example of an asynchronous request which was solved with OperationQueue . However, I do not succeed to achieve the same with Alamofire. public func performAlamofireRequest(_ number: Int, success: @escaping (Int) -> Void)->Void { Alamofire.request(String(format: "http://jsonplaceholder.typicode.com/posts/%i", number+1)) // NSURLSession dispatch queue .responseString { response in // Completion