alamofire

How to send a request with alamofire with xml Body

£可爱£侵袭症+ 提交于 2019-11-30 18:59:30
问题 I installed Alamofire in my project and now here is what I have done. I installed postman and I put my url and inside body a xml object and I got my result. Here is a picture of what I exactly have done with postman How can I now use Alamofire or SWXMLHash to send it as I send it with postman Thanks in advance! EDIT I tried this from another question: Alamofire.request(.POST, "https://something.com" , parameters: Dictionary(), encoding: .Custom({ (convertible, params) in let mutableRequest =

Alamofire Error Domain=NSURLErrorDomain Code=-999 “cancelled”

醉酒当歌 提交于 2019-11-30 17:08:17
问题 I already have successfully got keychain for my token and passing it to AccessTokenAdapter class shown below. http127.0.0.1:8000/api2/projects/?format=json is passed as projectsURL. class AccessTokenAdapter: RequestAdapter { private let accessToken: String init(accessToken: String) { self.accessToken = accessToken } func adapt(_ urlRequest: URLRequest) throws -> URLRequest { var urlRequest = urlRequest // print("JWT \(accessToken)") urlRequest.setValue("JWT \(accessToken)", forHTTPHeaderField

Live search throttle in Swift 3

自作多情 提交于 2019-11-30 17:07:16
问题 I'm trying to live search at my PHP API with Swift. Until now i've done this thing. var filteredData = [Products]() func getSearch(completed: @escaping DownloadComplete, searchString: String) { let parameters: Parameters = [ "action" : "search", "subaction" : "get", "product_name" : searchString, "limit" : "0,30" ] Alamofire.request(baseurl, method: .get, parameters: parameters).responseJSON { (responseData) -> Void in if((responseData.result.value) != nil) { let result = responseData.result

How to install the Alamofire 4.0 in Xcode 8.0

一笑奈何 提交于 2019-11-30 16:45:51
I am using the updated Xcode 8.0. How to install the alamofire 4.0 using cocoa pods. i am tried this one https://github.com/Alamofire/Alamofire . am getting an error when i convert the swift Just follow these easy step >>>>> 1 Open Terminal and Type gem install cocoapods 2 Create Xcode project and set directory of project in terminal and and write pod init 3 A pod file will created, open it and write this - source 'https://github.com/CocoaPods/Specs.git' platform :ios, '10.0' use_frameworks! target '<Your Target Name>' do pod 'Alamofire', '~> 4.0' end 4 Save init file cmd+S 5 Finally write pod

How to install the Alamofire 4.0 in Xcode 8.0

和自甴很熟 提交于 2019-11-30 16:24:33
问题 I am using the updated Xcode 8.0. How to install the alamofire 4.0 using cocoa pods. i am tried this one https://github.com/Alamofire/Alamofire. am getting an error when i convert the swift 回答1: Just follow these easy step >>>>> 1 Open Terminal and Type gem install cocoapods 2 Create Xcode project and set directory of project in terminal and and write pod init 3 A pod file will created, open it and write this - source 'https://github.com/CocoaPods/Specs.git' platform :ios, '10.0' use

How to implement self signed certificates in Alamofire?

核能气质少年 提交于 2019-11-30 15:55:50
I write a swift based app with a self signed certificate server communication. As a network library I want to use Alamofire. However Alamofire doesn't support self signed certificates. Is it possible to implement this feature easily and how? This feature is not yet supported by Alamofire. It will most likely be added eventually by the community, but that work has yet to be submitted to the project. If you feel like contributing this feature, by all means fork the repo and submit a pull request. If you want to learn how to implement this feature yourself, I'd suggest you read up on SSL pinning

How to handle multiple network call in Alamofire

依然范特西╮ 提交于 2019-11-30 15:35:37
问题 I need to call 2 apis in a view controller to fetch some data from server, I want them to start at the same time, but next step will only be triggered if both of them are returned(doesn't matter it's a success or failure). I can come up with 2 solutions : 1. Chain them together. Call api1, call api2 in api1's result handler, wait for api2's result 2. Set 2 Bool indicator variables, create a check function, if both of these indicators are true, do next. In both Apis result handler, set

Could not cast value of type 'NSMutableURLRequest' (0x11beb7040) to 'Alamofire.URLRequestConvertible' (0x11beb9040)

会有一股神秘感。 提交于 2019-11-30 15:30:27
when build my code then crash on Alamofire.request(request as! URLRequestConvertible).responseJSON() . pls suggest how to fix this crash let url = NSURL(string: "https://jsonplaceholder.typicode.com/users") let request = NSMutableURLRequest(url:url! as URL) request.httpMethod = "GET" request.setValue("application/json", forHTTPHeaderField: "Content-Type") Alamofire.request(request as! URLRequestConvertible).responseJSON(){ response in switch response.result { case .success(let data): print(" i got my Data Yup",data) case .failure(let error): print(error) } } In Swift 3, all you have to do is

'NSInvalidArgumentException', reason: 'Invalid type in JSON write (_SwiftValue)' with alamofire swift3

回眸只為那壹抹淺笑 提交于 2019-11-30 15:13:52
问题 I've encountered following error while uploading Swift3 using XCode8. 'NSInvalidArgumentException', reason: 'Invalid type in JSON write (_SwiftValue)' let param: Parameters = [ "email":txrNRC.text as AnyObject, "password":txtPassword.text as AnyObject ] Please let me know how to solve that issue. I've already tried with let param: NSDictionary but got same error message. 回答1: First of all in Swift 3 the Objective-C equivalent of id is Any rather than AnyObject , that avoids also the AnyObject

Alamofire loading from cache even when cache policy set to ReloadIgnoringLocalAndRemoteCacheData

自作多情 提交于 2019-11-30 14:46:19
问题 I set cache policy to request in Alamofire to ignore local cache. Then I load a viewcontroller with network connection, then I disconnect network connection, kill the app and run it again. Now no network available error is not shown(ie alamofire doesnt create nserror object) created, instead app runs as if the request succeeded getting data from cache obviously.And the odd thing is the when I tried to inspect the cached data using NSURLCache.sharedURLCache().cachedResponseForRequest(request)