alamofire

Extra argument 'method' in call

故事扮演 提交于 2019-11-29 02:47:43
Getting error while calling Alamofire request method in the latest version(4.0.0). The syntax is: Alamofire.request(urlString,method: .post, parameters: requestParams, encoding: .JSON, headers: [:]) the type of requestParam is [String:Any] I got the issue, I have to use JSONEncoding.default instead of .JSON, so the new syntax is Alamofire.request(urlString,method: .post, parameters: requestParams, encoding: JSONEncoding.default, headers: [:]) I can only refer you to: https://github.com/Alamofire/Alamofire/issues/1508#issuecomment-246207682 Basically, if one of your parameters is of the wrong

Using Alamofire within a Playground

那年仲夏 提交于 2019-11-29 01:41:20
I'm new to iOS development and using Xcode and I'm having trouble getting Alamofire to work within a Playground. There's some functionality I'd like to test out for proof of concept but the library is not linked to the Playground and I've tried getting it to play nicely. I have Alamofire set up to work within an iOS (not in a Playground) project before the installation instructions in the Github Alamofire repo were recently updated. Any suggestions on how to get Alamofire to import properly in the Playground? Canucklesandwich Apple provides excellent step-by-step instruction to do so here:

How to send POST request with both parameter and body for JSON data in Swift 3 using Alamofire 4?

巧了我就是萌 提交于 2019-11-29 00:02:24
问题 Postman api url added below. Present code : let baseUrl = "abc.com/search/" let param = [ "page":"1", "size":"5", "sortBy":"profile_locality" ] let headers = [ "Content-Type": "application/json" ] Alamofire.SessionManager.default.request("\(baseUrl)field", method: .post,parameters: param, encoding: JSONEncoding.default, headers: headers).responseJSON { response in print(response.request ?? "no request") // original URL request if(response.response?.statusCode != nil){ print("done") if self

Alamofire 4.0 & swift 3.0 学习

爱⌒轻易说出口 提交于 2019-11-28 22:57:47
  在这前,已经介绍并学习过 AFNetworking 源码了,现在通过阅读学习Alamofire最新源码同时,学习swift 3.0这门语言,虽然swift programming language已经看过,但是没有实际例子语法性的东西真的很容易就忘记。这里会简单绍Alamofire最新源码的架构,并且学习swift 3.0这门语言,透过Alamofire学习优秀的swift 3.0用法并记录,加深记忆。      Alamofire 简述    其实alamofire跟 AFNetworking 做的事情是一样的,所以会非常想似,架构,思路等,所以细节实现并不会很深入写。大概的类结构及关系如下: 1、Alamofire是用来提供对外接口的,最终调用都被接到SessionManager,SessionManager依赖ParameterEncoding把参数,数据等生成请求,再依赖SessionDelegate生成sessionTask,每个task都与TaskDelegate成对的包装在Request里。服务器数据的返回会很到SessionDelegate,到被分发到对应的taskDelegate。当完成时,就会调用Request预设置的block任务。前依赖ResponseSerializer对数据进行返序列化,再通过block回调给使用者。以下为它的流程图: 说明

Module file was created by an older version of the compiler

送分小仙女□ 提交于 2019-11-28 22:49:32
Using Carthage to manage my dependencies, everything runs fine in the simulator. However, when building for a device I get the following error: Module File was created by an older version of the compiler; rebuild Alamofire and try again: .../DerivedData/Build/Products/Debug-iPhones... I have tried what others suggested to similar issues: deleting my derived data, reinstalling Carthage and rebuilding the frameworks. However, the error has been persistent. Are you using the right version of xcodebuild? What do you see when you run xcode-select -p? It should be pointed at Xcode 7 if you want to

Swift Alamofire VS AFNetworking

不问归期 提交于 2019-11-28 21:59:09
问题 I am developing an app using Swift. I want to call a REST API. I found there are two popular libraries, AFNetworking and Alamofire. But I don't know which is better (is more popular or has more features). Can anybody suggest what are the main differences between Alamofire and AFNetworking? 回答1: Use AFNetworking if you use Objective-C Use Alamofire if you use Swift 回答2: AFNetworking and Alamofire are by the same people (the Alamofire Software Foundation), Alamofire is their Swift version

Alamofire 4.0 Upload MultipartFormData Header

↘锁芯ラ 提交于 2019-11-28 21:18:01
How do we add an authentication header to the upload function of Alamofire 4.0? below is the sample code, however I see no way in adding a header to the function. Alamofire.upload( multipartFormData: { multipartFormData in multipartFormData.append(unicornImageURL, withName: "unicorn") multipartFormData.append(rainbowImageURL, withName: "rainbow") }, to: "https://httpbin.org/post", encodingCompletion: { encodingResult in switch encodingResult { case .success(let upload, _, _): upload.responseJSON { response in debugPrint(response) } case .failure(let encodingError): print(encodingError) } } )

Any way to get the response body during HTTP errors?

女生的网名这么多〃 提交于 2019-11-28 19:07:54
I'm hitting an API that will occasionally throw a HTTP 403 error, and the response body can give some extra information in the form of json, however for the life of me I can't seem to get the information back out from the Alamofire response objects. I see the information in developer tools if I hit the API via chrome. Here's my code: Alamofire.request(mutableURLRequest).validate().responseJSON() { (response) in switch response.result { case .Success(let data): if let jsonResult = data as? NSDictionary { completion(jsonResult, error: nil) } else if let jsonArray = data as? NSArray { let

How to add Alamofire URL parameters

痞子三分冷 提交于 2019-11-28 18:43:10
I have a working scenario using Postman passing in URL parameters. Now when I try to do it via Alamofire in Swift, it does not work. How would you create this url in Alamofire? http://localhost:8080/?test=123 _url = "http://localhost:8080/" let parameters: Parameters = [ "test": "123" ] Alamofire.request(_url, method: .post, parameters: parameters, encoding: URLEncoding.default, headers: headers The problem is that you're using URLEncoding.default . Alamofire interprets URLEncoding.default differently depending on the HTTP method you're using. For GET , HEAD , and DELETE requests, URLEncoding

How to load image in swift using Alamofire

喜你入骨 提交于 2019-11-28 18:39:41
I have a collection view controller, which load image Async by URL. (Something like Instegram) I am looking for the best way to implement the part of the loading image. please tell me what do you think First way - without any external library: let downloadQueue = dispatch_queue_create("com.pro.asyncImages",nil) dispatch_async(downloadQueue){ var data = NSData(contentsOfURL: NSURL(string: pictureUrl!)!) var image: UIImage? if (data != nil){ image = UIImage(data: data!) } dispatch_async(dispatch_get_main_queue()){ uiImageView.image = image } } Second way - using Alamofire (the request belong to