alamofire

Run Alamofire request after finishing another Alamofire request

两盒软妹~` 提交于 2019-12-31 07:21:52
问题 I would like to run an Alamofire request that is using the result of a previous Alamofire request as a parameter. To make it simple: //Code1 Alamofire.request("URL", method: HTTPMethod.post, parameters: ["id": id as NSString)], encoding: URLEncoding.httpBody).response(completionHandler: { (response) in let json = response.data do { print("This should be First") let data = try JSON(data: json!) let alllastmessages = data["Messages"].arrayValue for i in 0..<alllastmessages.count { self.List

Alamofire 4 error request 'extra argument in call'

给你一囗甜甜゛ 提交于 2019-12-31 05:22:05
问题 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 {

Alamofire 5 Escaping Forward Slashes

痴心易碎 提交于 2019-12-31 04:03:10
问题 Ive been googling and trying for the last few days regarding the automatic escaping of forward slashes of alamofire. (Where "/path/image.png" becomes "\/path\/image.png") However all the answers either point towards a solution if your using swiftyJson, sending via a httpBody or using the Alamofire Parameter Class. https://github.com/SwiftyJSON/SwiftyJSON/issues/440 Im not using SwiftyJson and feel to install the API just to resolve the issue is a case of hitting the nail with a sledge hammer.

Swift iOS 9 NSURLErrorDomain Error -1004

血红的双手。 提交于 2019-12-31 03:23:30
问题 I'm using Swift 2 and Alamofire with both iOS 9 and iOS 8. In iOS 8 all my requests to my API work fine. In iOS 9 they immediately fail with a -1004 NSURLErrorDomain with the message "Could not connect to the server.". I read about Apple's change with App Transport Security and already added the entry to my Plist to disable it and allow insecure connections. I'm at a loss as to the reason for this error...any help would be great! 回答1: After messing around with a ton of different keys and

How to upload MultipartFormData with authentication using Alamofire

时光怂恿深爱的人放手 提交于 2019-12-31 02:51:08
问题 How to upload MultipartFormData with authentication using Alamofire? The part that I don't understand is where to put .authenticate(user: username, password: password). ? This is how I usually upload pictures using MultipartFormData : Alamofire.upload( .POST, "https://myExampleUrl/photo/upload", headers: headers, multipartFormData: { multipartFormData in multipartFormData.appendBodyPart(data: "default".dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)!, name :"_formname")

Return Bool in Alamofire closure

心不动则不痛 提交于 2019-12-30 22:53:51
问题 I use Swift 2 and Xcode 7.1. I have a function who connect my users, but it will connect at my database with HTTP. I use Alamofire for execute this request. I want to know, from a view controller if the user is connected. I have my function connect in a class. And i test connection in a ViewController. Like this : class user { // ... func connectUser(username: String, password: String){ let urlHost = "http://localhost:8888/project350705/web/app_dev.php/API/connect/" let parametersSymfonyG = [

Return Bool in Alamofire closure

牧云@^-^@ 提交于 2019-12-30 22:53:42
问题 I use Swift 2 and Xcode 7.1. I have a function who connect my users, but it will connect at my database with HTTP. I use Alamofire for execute this request. I want to know, from a view controller if the user is connected. I have my function connect in a class. And i test connection in a ViewController. Like this : class user { // ... func connectUser(username: String, password: String){ let urlHost = "http://localhost:8888/project350705/web/app_dev.php/API/connect/" let parametersSymfonyG = [

Uploading multiple image files with Swift

江枫思渺然 提交于 2019-12-30 11:56:31
问题 Im using the following code to upload a single image to a server (with parameters), However I've been trying to upload multiple images, but could not get it to work Creating NSData objects (of images saved in temp directory). Using netdata class here func uploadData(){ //create image data objects let filemanager:NSFileManager = NSFileManager() let files = filemanager.enumeratorAtPath(tempPicPath) var counter:Int = Int() while let file: AnyObject = files?.nextObject() { imagePathCollection

Alamofire, Objectmapper, Realm: Nested Objects

流过昼夜 提交于 2019-12-30 09:39:13
问题 I'm using Alamofire, Objectmapper, Realm and everything is working beside one thing: I can't map nested objects. class Voting: Object, Mappable { dynamic var votingID: String = "" dynamic var question: String = "" var votingOptions = List<VotingOption>() required convenience init?(_ map: Map) { self.init() } func mapping(map: Map) { votingID <- map["id"] question <- map["question"] votingOptions <- map["votingOptions"] } override class func primaryKey() -> String { return "votingID" } } class

How to execute alamofire background upload request?

孤街醉人 提交于 2019-12-30 09:37:47
问题 I need to send zip file to server side. There is my request which I need to work in background let configuration = URLSessionConfiguration.default configuration.timeoutIntervalForRequest = 10 // seconds alamoFireManager = Alamofire.SessionManager(configuration: configuration) appDeligate.log.debug("request was sended") alamoFireManager.upload(deligate.data!, to: deligate.url, method: .post, headers: headers) .uploadProgress(closure: { progress in print("Upload Progress: \(progress