alamofire

Swift Resume Alamofire upload after timeout/lost connection

烂漫一生 提交于 2019-12-10 13:17:57
问题 Im using swift 2.3 and Alamofire with multipartFormData to upload files asynchrononously and cant seem to figure out if it even is possible to make a resume after i get a timeout on my connection or lost my connection and it is reestablished on the phone. What I want is to resume the upload if it fails, for example: I upload a large file. It gets to 55% uploaded, and then I lose my internet connection. When I regain the internet connection, I want the upload to continue from 55% instead of

Alamofire4 trouble with JSONResponseSerializer & HTTPURLResponse Swift 3.0

女生的网名这么多〃 提交于 2019-12-10 11:26:10
问题 Since I updated Alamofire I get the errors: Type Request has no member JSONResponseSerializer and cannot call value of non-function type HTTPURLResponse I have already switched Response to DataResponse but I still get the error. Code: extension Alamofire.Request { func responseUserEventsArray(_ completionHandler: @escaping (DataResponse<UserEventsWrapper>) -> Void) -> Self { let responseSerializer = DataResponseSerializer<UserEventsWrapper> { request, response, data, error in guard error ==

How to convert json data from alamofire to swift objects

微笑、不失礼 提交于 2019-12-10 10:39:08
问题 hi there im making a photo viewer app in swift using swift 1.1 in xcode 6.2 i am a having trouble trying to convert json response from alamofire to swift objects.i have used swiftyjson library but it seems there is a compatibility issues.here is my model class import Foundation struct Photo { var name: String var filename :String var notes: String } here is my viewController import UIKit class ImageViewerTableViewController: UITableViewController { var photos = [Photo]() override func

Ambigious reference to member request() issues with Alamofire after migration to swift 3

99封情书 提交于 2019-12-10 03:54:20
问题 So I am new to swift as a whole so bear with me.. I had the query working in swift 2 but after I migrated to swift 3 I get the error Ambiguous reference to member 'request(_:withMethod:parameters:encoding:headers:)' Below is the code in which it occurs: Alamofire.request(.GET, serverRequest).validate().responseJSON( { response in switch response.result{ case .Success: if let JSON = response.result.value { let final = JSON[wantedClass] as! String//forces output to string self.failure("You

Do I need to wrap my Alamofire calls inside dispatch_async?

给你一囗甜甜゛ 提交于 2019-12-10 03:10:53
问题 func authenticate(completion:(success: Bool) -> Void) { let qos = Int(QOS_CLASS_USER_INITIATED.value) dispatch_async(dispatch_get_global_queue(qos, 0)){ () -> Void in Alamofire.request(.POST, CONSTANTS.Domain+"/accounts", parameters: ["" : ""]).responseJSON { (req, res, json, error) in dispatch_async(dispatch_get_main_queue()){ completion(success: true) } } } } Or, can I leave out the dispatch and just keep my code simple? 回答1: Alamofire is designed to be asynchronous. On another note, if the

Xcode can't find Alamofire, error: No such module 'Alamofire'

老子叫甜甜 提交于 2019-12-10 03:01:03
问题 I'm trying to include Alamofire in my Swift project following the github(https://github.com/Alamofire/Alamofire#cocoapods) instruction. I've created a new project, navigated to the project directory and run this command sudo gem install cocoapods . Then I faced following error: ERROR: While executing gem ... (Errno::EPERM) Operation not permitted - /usr/bin/pod After searching I managed to install cocoapods by running this command sudo gem install -n /usr/local/bin cocoapods Now I generate a

Alamofire 4.0 RequestRetrier should(_,retry,with,completion) not being called

空扰寡人 提交于 2019-12-10 01:13:57
问题 I am using the RequestRetrier of Alamofire 4.0 to control the retrying of requests for expired access token. I am following the documentation here. I have a very similar implementation to the example available in the documentation OAuth2Handler which implements RequestAdapter and RequestRetrier . The issue I am encountering is that func should(_ manager: SessionManager, retry request: Request, with error: Error, completion: @escaping RequestRetryCompletion) is never being called. The adapt

Swift client and root SSL certificate authentication

半腔热情 提交于 2019-12-09 23:52:47
问题 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 =

Create JSON Object from Class in Swift

我的未来我决定 提交于 2019-12-09 19:10:25
问题 I'm pretty new to iOS development and Swift (so please bear with me). I have a class object defined like this: class LocationPoint { var x: Double var y: Double var orientation: Double init(x: Double, y: Double, orientation: Double) { self.x = x self.y = y self.orientation = orientation } } In my delegate, I create an instance of the class and append it to an array (declared outside the delegate): var pt = LocationPoint(x: position.x, y: position.y, orientation: position.orientation) self

AlamofireImage Disk Cache not working

北城余情 提交于 2019-12-09 17:34:58
问题 I want to use AlamofireImage to download images from an url and then cache it on the device disk space. I read several posts about this and found out that AlamofireImage supports this with the help of the ImageDownloader class. The most interesting information was given in this SO answer So I tried to set a custom NSURLCache for the ImageDownloader so that it would cache the images directly to the disk. I did that by setting the memory capacity to 0. Then I use this custom ImageDownloader to