alamofire

How to cancel all requests in Alamofire's shared manager

白昼怎懂夜的黑 提交于 2019-12-10 17:35:08
问题 How to cancel all requests in Alamofire's shared manager? This is my function: class func cancelAllRequests() { Alamofire.Manager.sharedInstance.session.getTasksWithCompletionHandler { (dataTasks, uploadTasks, downloadTasks) in self.each(dataTasks, function: self.cancel) self.each(uploadTasks, function: self.cancel) self.each(downloadTasks, function: self.cancel) } } class func cancel(index: Int, element: AnyObject) { if let task = element as? NSURLSessionTask { task.cancel() } } class func

Mapping to Swift Object issue showing nil using Alamofire ObjectMapper

不打扰是莪最后的温柔 提交于 2019-12-10 17:34:10
问题 I m new to iOS and Swift development environment. I was trying to use Alamofire for pulling JSON and AlamofireObjectMapper for Mapping the retrieved JSON collections back to my Swift Object. The issue is I m able to fetch the JSON thru Alamofire request and the count is shown, but the mapping part seems to be showing nil. Is something I had been missed out . Appreciate help. Model Class import UIKit import CoreLocation import ObjectMapper class BranchObjectMapper : Mappable { // MARK:

Cannot call value of non-function type 'NSHTTPURLResponse?'

删除回忆录丶 提交于 2019-12-10 17:32:26
问题 I've seen this problem a few times on this site but none of the solutions seem to work. I am extending the alamofire request to have an array of repo objects as a result; however, I keep getting the error in the title. Here is the code: extension Alamofire.Request { class func repoArrayResponseSerializer() -> ResponseSerializer<Array<Repo>, NSError> { return ResponseSerializer { request, response, data, error in guard error == nil else { return .Failure(error!) } guard data != nil else {

unexpectedly found nil while unwrapping an Optional value - Using ALAMOFIRE

ⅰ亾dé卋堺 提交于 2019-12-10 17:16:58
问题 I am trying to use Alamofire for GETs in JSON. When I use one URL - It works fine and when I use another I get an error unwrapping an optional value. I cannot seem to track where the error is coming from. I have resorted in putting the code in ViewDidLoad to track the error. I don't know if its the recipient and they want some sort of authorisation. but I know its not the println's cos when i // them - it still comes up as an error , heres the code : request(.GET, "https://api.doingdata.net

Image downloading with progress using AlamofireImage?

孤街醉人 提交于 2019-12-10 15:55:36
问题 Is there any way to download an image using AlamofireImage and get some kind of feedback about the download progress while leveraging the power of it's UIImage Extensions, Image Filters and Image Cache ? I know I can fallback to a plain Alamofire.request + responseImage but I'd like to keep things simple and make use of the UIImageView Extension . Thank you! 回答1: There is not any way at the moment to use AlamofireImage alongside the UIImageView extension to receive progress updates when

Alamofire - not be code signed because its settings don't specify a development team in Xcode 8

这一生的挚爱 提交于 2019-12-10 15:29:32
问题 I hit the error on below on Xcode 8, can everyone help to solve it. My application need to support iOS 8 and above. Alamofire will not be code signed because its settings don't specify a development team. “Use Legacy Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift version or use the Build Settings editor to configure the build setting directly. Thanks 回答1:

How to have a completion handler/block after Alamofire Post request?

眉间皱痕 提交于 2019-12-10 15:19:48
问题 I have a method which handles a Apple Push Notification Service remote notification. When this method is executed, I want it to call my server and do a HTTP POST request using the Alamofire library. I want to execute another method that will handle the response of the POST request. The problem for me is that I am using an existing API to fetch a profile from the server in this POST request. So I need to use this existing API and figure out when this profile fetch is specifically triggered

Xcode 9 - Alamofire Pods. Command /bin/sh failed with exit code 1

ぃ、小莉子 提交于 2019-12-10 14:45:52
问题 /Users/Alex/Library/Developer/Xcode/DerivedData/MyProject-ehabmnclpzlywhabrefntacibonm/Build/Intermediates.noindex/ArchiveIntermediates/Fuego/InstallationBuildProductsLocation/Applications//MyProject.app/Frameworks/Alamofire.framework: unknown error -1=ffffffffffffffff Command /bin/sh failed with exit code 1 I got this issue when I Archive my project. When I run app on simulator it works ok without such issue above. Also it works ok with Xcode 8 , but now when I try to Archive it on Xcode 9 I

Sending array of dictionaries with alamofire

跟風遠走 提交于 2019-12-10 13:27:31
问题 I have to send array of dictionaries via POST request. For example: materials: [[String, String]] = [ [ "material_id": 1, "qty": 10 ], [ "material_id": 2, "qty": 5 ] ] Alamofire.request sends the next post data: materials => array( [0] => array("material_id" => 1), [1] => array("qty" => 10), [2] => array("material_id" => 2), [3] => array("qty" => 5), ) I want receive that representation: materials => array( [0] => array( "material_id" => 1, "qty" => 10 ), [1] => array( "material_id" => 2,

swift error “Domain=NSCocoaErrorDomain Code=3840 ”Invalid value around character 1."

旧街凉风 提交于 2019-12-10 13:21:21
问题 I am having trouble fixing this error message on my Swift Alamofire POST request (to login a user). '3840' "Invalid value around character 1." I have imported Foundation, Alamofire , SwiftyJson . There are no authorisation restrictions (no Oauth etc). I'm also getting the same error message when I change the Post (eg to another endpoint, with other parameters and values) but keep the rest of the code/format the same. On my drupal7 REST server 'definitions' it lists the endpoint as /rest/user