alamofire

Swift Alamofire Request Error - Extra Argument in call

99封情书 提交于 2019-12-25 08:41:01
问题 I am getting an error when I am trying to request using Alamofire. The error says that there is an 'extra argument in call'. class SwiftStockKit { class func fetchStocksFromSearchTerm(term: String, completion:@escaping (_ stockInfoArray: [StockSearchResult]) -> ()) { DispatchQueue.global(priority: DispatchQueue.GlobalQueuePriority.default).async { let searchURL = "http://autoc.finance.yahoo.com/autoc" Alamofire.request(.GET, searchURL, parameters: ["query": term, "region": 2, "lang": "en"])

Pull to refresh and Alamofire using Swift 3

青春壹個敷衍的年華 提交于 2019-12-25 08:15:41
问题 I am using Alamofire to get data from a web URL(JSON). I am trying to implement pull to RefreshControl into my project. I have done it but don't know if it is correct or if the data is getting updated when refreshed. My code is: var refresh = UIRefreshControl() refresh.addTarget(self, action: #selector(self.refreshData), for: UIControlEvents.valueChanged) func refreshData() { Alamofire.request("https://www.example.com/api").responseJSON(completionHandler: { response in self.parseData(JSONData

JSON structure with Swift and Alamofire

泄露秘密 提交于 2019-12-25 07:48:04
问题 Following on from This question I am trying to bring in the summary field but it has a further value. I have brought in the title and author as follows: func parseData(JSONData : Data) { do { var readableJSON = try JSONSerialization.jsonObject(with: JSONData, options: .mutableContainers) as! JSONstandard // print(readableJSON) if let posts = readableJSON["posts"] as? [JSONstandard] { for post in posts { let title = post["title"] as! String let author = post["author"] as! String let summary =

Alamofire never calls encodingCompletion for upload with MultipartFormData when main thread is waiting for it to run

风流意气都作罢 提交于 2019-12-25 06:57:35
问题 I have code of this form: func myFunction(<...>, completionHandler: (ResponseType) -> Void) { <prepare parameters> mySessionManager.upload(multipartFormData: someClosure, to: saveUrl, method: .post, headers: headers) { encodingResult in // encodingCompletion switch encodingResult { case .failure(let err): completionHandler(.error(err)) case .success(let request, _, _): request.response(queue: self.asyncQueue) { response in // upload completion <extract result> completionHandler(.success

SequenceType Generator Generic Swift

寵の児 提交于 2019-12-25 06:12:20
问题 I'm having some issues trying to run this code, I found couple examples using the same code but I get compiler error Undefined symbols for architecture arm64: "ExpSwift.SearchResults.generate () -> Swift.IndexingGenerator<[A]>", referenced from: ExpSwift_Example.ViewController.(viewDidLoad () -> ()).(closure #1).(closure #3) in ViewController.o ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation) here is my code class

(_, _, _) -> Void' is not convertible to 'Response<AnyObject, NSError> -> Void'

一世执手 提交于 2019-12-25 06:07:46
问题 I imported Alamofire the way I used to successfully import it, and when I had this code, there comes an error: Alamofire.request(.GET, postEndPoint).responseJSON {(request, response, result) in //Error: '(_, _, _) -> Void' is not convertible to 'Response<AnyObject, NSError> -> Void' guard let value = result.value else { print("Error: did not receive data") return } guard result.error == nil else { print("error calling GET on /posts/1") print(result.error) return } let post = JSON(value) print

What is the proper API calling Syntax from Alamofire?

99封情书 提交于 2019-12-25 06:04:04
问题 I am trying to call following API: http -v -a qi.test.ac@gmail.com:pasword -f POST 'http://localhost:8080/api/v1/user/messages' from="qi.test.ac@gmail.com" to={"qi.test.ac@gmail.com","qi_test_ac@yahoo.com"} subject="test_sub" bodyText="testing hello" I successfully called it from terminal using HTTPie using normally above command. Now I want to call it from Alamofire. I have tried in following way: parameters = [ "from" : fromMail, "to" : ["qi.test.ac@gmail.com","qi_test_ac@yahoo.com"] ]

Error - Resquest function with Alamofire and AlamofireObjectMapper (swift - iOS)

孤人 提交于 2019-12-25 05:04:54
问题 First of all, I'm a beginner and I'm trying to build an app that search a movie on OMDB API and return a list of movie (when searched by title) and return an specific movie when searched by imdbID. I have to make two types of request for the api, because the result for search by id have the same atributes that the search by title have but with more details (need this to show a view with a selected movie from this list of results). So, it was recommended to me (here) to use

Alamofire treat specific error codes

前提是你 提交于 2019-12-25 04:11:05
问题 My aim is to be able to catch whatever response in Alamofire requests (JSON, string) before my final competition handler is called and if it is a specific response code than I treat it the same for all responses. I did a wrapper around Alamofire which let's me do specific requests I need (login request etc.) and there I catch the responses also, but I don't want to treat my error codes that are common globally in every specific request. It seems more naturally to just subclass Alamofire

Alamofire treat specific error codes

主宰稳场 提交于 2019-12-25 04:10:12
问题 My aim is to be able to catch whatever response in Alamofire requests (JSON, string) before my final competition handler is called and if it is a specific response code than I treat it the same for all responses. I did a wrapper around Alamofire which let's me do specific requests I need (login request etc.) and there I catch the responses also, but I don't want to treat my error codes that are common globally in every specific request. It seems more naturally to just subclass Alamofire