alamofire

Moya/Alamofire - URL encoded params with same keys

為{幸葍}努か 提交于 2019-12-05 01:32:17
问题 I'm using Moya Swift framework for networking layer which is constructed on top of Alamofire. Currently, I'm trying to send request with URL encoded parameters that have same keys. i.e. http://some-site/request?param=v1&param=v2&param=v3 I've already tried to group these params into Set or NSSet or Array like this but nothing helps to achieve desired result. ["param": ["v1", "v2", "v3"]]; ["param": Set(arrayLiteral: "v1", "v2", "v3")] Any help would be appreciated either with Moya or with

Alamofire framework not found

 ̄綄美尐妖づ 提交于 2019-12-05 01:11:37
I am trying to install alamofire into my project so I can upload images to my server, however I cannot seem to find the alamofire.framework file. I have downloaded the git twice, done the installation instructions on https://github.com/Alamofire/Alamofire but when it comes to step 6 , how and where do I get the alamofire.framework file? I am new to this, so sorry if it is a stupid question. You have to open yourprojectname.xcworkspace You might get this error if you are opening your .xcworkproj instead of workspace Close your Xcode project Re-Open your project with the Xcode workspace file and

Alamofire 3 Custom Encoding To Alamofire 4 Custom Encoding

巧了我就是萌 提交于 2019-12-04 23:37:27
问题 I have method writing in Alamofire 3 with customParameterEncoding. This custom encoding just replaces "[]=" with "=" in queryString and returns it. Alamofire.request(.GET, SearchURL, parameters: params, encoding: customEncoding, headers: headers).validate().responseJSON { response in switch response.result { case .success: print("success") break case .failure(let error): print("Error: " + error.localizedDescription) break } } and custom encoding parameter let customEncoding =

Use 3rd party pod in sub-project (framework project)

我是研究僧i 提交于 2019-12-04 22:54:52
I am using XCode 8 + Swift 3. I created a fresh iOS project named " MyApp ". Then, I create a Cocoa touch framework project, named "MySubProject". (The idea is to have MyApp project accessing MySubProject code.) They are on the same level folder: - MyApp/ - MySubProject/ I added MySubProject into MyApp project, linked the MySubProject framework. Everything works fine. My project structure looks like this: All works until here! (MyApp code can access MyService code) Now, I need MySubProject to use Alamofire to communicate with backend. So, under MySubProject/ I setup the Alamofire with CocoaPod

what is the advantage of using Alamofire over NSURLSession/NSURLConnection for networking?

依然范特西╮ 提交于 2019-12-04 22:33:05
Can anyone help me in understanding these question : What is the advantage of using Alamofire over NSURLSession/ NSURLConnection? What are the differences between NSURLSession and NSURLConnection? NSURLConnection is Apple's old API for doing networking (e.g. making HTTP requests and receiving responces), while NSURLSession is their new one. The latter one is higher level and is generally much easier and involves less boilerplate code to use for most application developers - there's basically no reason to use the former except in legacy code that you don't want to update. A bit of history:

Upload image with alamofire

时光怂恿深爱的人放手 提交于 2019-12-04 22:02:00
问题 I'm trying to upload an image to server with Alamofire but my code doesn't work. This is my code: var parameters = ["image": "1.jpg"] let image = UIImage(named: "1.jpg") let imageData = UIImagePNGRepresentation(image) let urlRequest = urlRequestWithComponents("http://tranthanhphongcntt.esy.es/task_manager/IOSFileUpload/", parameters: parameters, imageData: imageData) Alamofire.upload(urlRequest.0, data: urlRequest.1) .progress { (bytesWritten, totalBytesWritten, totalBytesExpectedToWrite) in

Unable to connect from IPv6 to IPv4 Error Domain=NSURLErrorDomain Code=-1003 \"A server with the specified hostname could not be found

柔情痞子 提交于 2019-12-04 21:16:40
I got the below error, while calling API from my iOS app (device) to server. My device is connected to IPv6 network & API which i am calling is with IPv4 network. I created the app using swift and i am using Alamofire for calling API and Reachability for checking Internet connection. What should i do for this. Please suggest on the below error. Request failed with error: Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found." UserInfo= {NSErrorFailingURLStringKey=, _kCFStreamErrorCodeKey=8, NSErrorFailingURLKey=, NSLocalizedDescription=A server with

Swift client and root SSL certificate authentication

喜夏-厌秋 提交于 2019-12-04 18:17:00
Integrating get token api of QLIK server with ssl certificate but after performing task I am getting error like this - " finished with error - code: -999 " // Your hostname and endpoint let hostname = "YOUR_HOST_NAME" let endpoint = "YOUR_ENDPOINT" let cert = "YOUR_CERT" // e.g. for cert.der, this should just be "cert" // Set up certificates let pathToCert = Bundle.main.path(forResource: cert, ofType: "der") let localCertificate = NSData(contentsOfFile: pathToCert!) let certificates = [SecCertificateCreateWithData(nil, localCertificate!)!] // Configure the trust policy manager let

How to get the download progress in bytes using Alamofire 4?

人盡茶涼 提交于 2019-12-04 18:03:55
I'm currently working on an iOS project which requires me to download 10 different files at once. I know the file size and the size of all the files combined but I'm struggling to find a way to calculate the progress across all download tasks. progress.totalUnitCount = object.size // The size of all the files combined for file in files { let destination: DownloadRequest.DownloadFileDestination = { _, _ in let path = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.applicationSupportDirectory, FileManager.SearchPathDomainMask.userDomainMask, true) let documentDirectoryPath:

How to sort JSON coming from Alamofire and return final JSON object (swiftyJSON)

最后都变了- 提交于 2019-12-04 17:10:47
I'm having trouble succinctly pulling data from an api, adding the users current location into the object and then sorting the data based on the calculated distance. The stackoverflow questions don't quite answer the problem I'm facing. See here: How to sort posts read from JSON server file in Swift . I'm currently loading api data from Alamofire and rendering that data with a UITableViewController. override func viewDidLoad() { super.viewDidLoad() titleLabel.title = q.capitalizedString Alamofire.request(.GET, "http://www.thesite.com/api/v1/things", parameters: ["q" : q]) .responseJSON {