alamofire

Upload multiple images in swift using Alamofire

≯℡__Kan透↙ 提交于 2019-11-28 04:46:23
I'm using the following code to upload a single image to a server: private static func urlRequestWithComponents(urlString:String, parameters:Dictionary<String, String>, imageData:NSData?, imageName: String) -> (URLRequestConvertible , NSData) { // create url request to send let mutableURLRequest = NSMutableURLRequest(URL: NSURL(string: urlString)!) mutableURLRequest.HTTPMethod = Alamofire.Method.POST.rawValue let boundaryConstant = "myRandomBoundary12345"; let contentType = "multipart/form-data;boundary="+boundaryConstant mutableURLRequest.setValue(contentType, forHTTPHeaderField: "Content

What are Embedded Binaries in Xcode?

允我心安 提交于 2019-11-28 04:38:06
I'm using Alamofire in a Swift project, and part of their manual installation instructions are to add Alamofire under Embedded Binaries in the General tab for my application target. What are Embedded Binaries ? Embedded binaries are binary files that are copied to your application bundle when you build the project. Use embedded binaries when your application relies on third-party frameworks so people can use your application without needing those frameworks installed on their machine. Embedded binaries keep users from having to manually install third-party frameworks. Your application uses the

Alamofire Type 'ParameterEncoding' has no member 'URL' Swift 3

给你一囗甜甜゛ 提交于 2019-11-28 04:19:03
问题 I am trying to migrate my codes from swift 2 version to swift 3 version. I could not migrate following code part and I did not find any solution for it. How can I do it? // MARK: URLRequestConvertible public var URLRequest: NSMutableURLRequest { let urlComponent = NSURLComponents(string: Router.baseURL)! urlComponent.path = Router.basePath.stringByAppendingString(path) let mutableURLRequest = NSMutableURLRequest(URL: urlComponent.URL!) mutableURLRequest.HTTPMethod = method.rawValue var

Swift. Could not build objective-c module 'Alamofire'

社会主义新天地 提交于 2019-11-28 04:01:54
Fresh vanilla submodule install of Alamofire, using XCode6 and following directions to a T. Something here just isn't fitting right. The error i'm getting is "Could not build objective-c module "alamofire" on import alamofire. Here is a screen shot of the error i'm getting: And my configuration: When this happens, just build the frameworks separately first. In your case: Change the scheme to Alamofire Build ( ⌘B ) Change back to your scheme Run Go into Developer/Xcode/DerivedData and delete the folder for your framework. (Or just delete DerivedData itself) If you have a build of you app in a

How to make a synchronous request using Alamofire?

柔情痞子 提交于 2019-11-28 02:55:50
问题 I am trying to do a synchronous request using Alamofire . I have looked on Stackoverflow and found this question: making an asynchronous alamofire request synchronous. I saw that the accepted answer uses completion to make Alamofire request synchronous but I cannot make it to work. This is my simplified code: func loadData(completion: (Bool)) -> (Int, [String], [String], [String]){ Alamofire.request(url!, method: .get, parameters: nil, encoding: JSONEncoding.default, headers: nil)

Proper usage of the Alamofire's URLRequestConvertible

老子叫甜甜 提交于 2019-11-28 02:42:58
I've read couple tutorials, README from @mattt but can't figure out couple things. What is the proper usage of URLRequestConvertible in real world API? It looks like if I will create one router by implementing URLRequestConvertible protocol for all API - it will be barely readable. Should I create one Router per endpoint? Second question most likely caused by lack of experience with Swift language. I can't figure out why enum is used for building router? Why we don't use class with static methods? here is an example (from Alamofire's README) enum Router: URLRequestConvertible { static let

Alamofire : How to handle errors globally

房东的猫 提交于 2019-11-28 02:42:20
My question is quite similar to this one, but for Alamofire : AFNetworking: Handle error globally and repeat request How to be able to catch globally an error (typically a 401) and handle it before other requests are made (and eventually failed if not managed) ? I was thinking of chaining a custom response handler, but that's silly to do it on each request of the app. Maybe subclassing, but which class should i subclass to handle that ? Handling refresh for 401 responses in an oauth flow is quite complicated given the parallel nature of NSURLSessions. I have spent quite some time building an

Alamofire: Sending JSON as request parameter

风格不统一 提交于 2019-11-28 02:25:27
I have an incredibly long array and string I want to send through Alamofire though I don't know how I would send raw JSON as a parameter. The JSON looks a little like { "skus":["8865594-CS,4387296-CS,1175540-CS...."], "listType": "H" } Instead of getting that to behave like a Swift array and then serializing, is there a way I can pass this JSON as a parameter in Alamofire? Thanks! Edit: I was able to pull a bit of magic in a text editor to get the params formatted in the style of a Swift array (as in var skus = ["abc", ...] ) so I made the skus and listType into a Dictionary, per Eric's advice

How to upload audio with Alamofire multipart upload?

旧时模样 提交于 2019-11-28 02:18:04
I want to upload and audio file with using Alamofire . I see other questions which are telling to use Multipart request to do that Here is the example i got form other question : Alamofire.upload( multipartFormData: { multipartFormData in multipartFormData.append(audioRecorder?.url, withName: "iosTest.mp3") //**this "withName:" is it the name of the file? }, to: "https://yourLinkGoesHere", encodingCompletion: { encodingResult in switch encodingResult { case .success(let upload, _, _): upload.responseJSON { response in debugPrint(response) } case .failure(let encodingError): print(encodingError

Swift 3.0, Alamofire 4.0 Extra argument 'method' in call

∥☆過路亽.° 提交于 2019-11-28 02:09:46
I have read all the questions on this issue this and this . I have the following code let fullURL = God.getFullURL(apiURL: self.apiUrl) if (getOrPost == God.POST) { Alamofire.request(fullURL, method: .POST, AnyObject: self.postData?, encoding:.JSONEncoding.default, headers: nil).responseJSON{ response in self.responseData = response.result.value } } else if (getOrPost == God.GET) { Alamofire.request(fullURL, method : .GET, Parameters: getData, encoding:.JSONEncoding.default, headers: nil).responseJSON{ response in self.responseData = response.result.value } } My Swift and Xcode versions are