alamofire

PromsieKit + Alamofire for loading paged HTTP Data

ぃ、小莉子 提交于 2021-01-28 19:06:51
问题 I am migrating some code from RestKit to Alamofire. I use MagicalRecord + AlamofireObjectMapper to map the JSON into CoreData objects. I am now faced with the following situation: My Data lives at this URL: http://domain.com/api/resources?start=XX&limit=YY Now I have to do this: Download the first page of data from a given URL using a page-size of 50 If the number of loaded objects is equal to the page-size increment the start parameter by the page size If the number is less than the page

Request Timed out with Code

最后都变了- 提交于 2021-01-28 07:25:33
问题 Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo={NSUnderlyingError=0x608000244a70 {Error Domain=kCFErrorDomainCFNetwork Code=-1001 "(null)" UserInfo={_kCFStreamErrorCodeKey=-2102, _kCFStreamErrorDomainKey=4}}, NSErrorFailingURLStringKey=http://www.dfdd, NSErrorFailingURLKey=http://www.dfdd.com, _kCFStreamErrorDomainKey=4, _kCFStreamErrorCodeKey=-2102, NSLocalizedDescription=The request timed out.} Am getting this response calling MY API.. am using alamofire to call

Alamofire + Combine + MVVM request example

孤街浪徒 提交于 2021-01-28 06:44:52
问题 in my view controller I have a property items to which I have a subscription and rendering my view. For this view controller I have a view model where I have load method like: @Published private(set) var items: [Item] = [] func load(params: [String: Any] = [:]) { self.isLoading = true self.subscription = WebRepo().index(params: params).sink(receiveCompletion: { [weak self] (completion) in switch completion { case .failure(let error): print("Error is: \(error.localizedDescription)") default:

Alamofire without evaluation and with sending client certificate

心已入冬 提交于 2021-01-28 06:20:22
问题 Hello i am currently going crazy with alamofire :). What I'm trying to do is to disable evaluation because server has no valid SSL certificate but I have to connect by https and I have to send a x509 certificate made on IOS device by OpenSSL I am currently using alamofire 4 and I was trying to do: open class CertTrustPolicyManager: ServerTrustPolicyManager { open override func serverTrustPolicy(forHost host: String) -> ServerTrustPolicy? { let policy = ServerTrustPolicy.disableEvaluation; //

How to use Alamofires ServerTrustPolicy.disableEvaluation in swift 5 alamofire 5.0.3

天涯浪子 提交于 2021-01-21 12:17:05
问题 in alamofire 4 I used this code to disable sever evaluation: private var Manager : Alamofire.Session = { // Create the server trust policies let serverTrustPolicies: [String: ServerTrustPolicy] = ["serverurl.com": .disableEvaluation] // Create custom manager let configuration = URLSessionConfiguration.default configuration.httpAdditionalHeaders = Alamofire.Session.defaultHTTPHeaders let man = Alamofire.Session( configuration: URLSessionConfiguration.default, serverTrustPolicyManager:

Alamofire auto refresh token and retry previous API call in iOS Swift 4

送分小仙女□ 提交于 2021-01-20 16:58:28
问题 now I'm working on an iOS application in Swift 4. Here I'm using Alamofire to integrate the API calls. I need to integrate the right way to auto-refresh the authentication token and retry the previous API calls. I'm storing the authentication token once I logged in successfully. So after login, in each API, I'm appending the token in the header part. And when if the token is expired I will get 401. That time I need to auto-refresh the authentication token and recall the same API again. How

Append Nested Objects in Parameters of multi-form Swift using Alamofire

*爱你&永不变心* 提交于 2020-12-30 04:49:25
问题 I am uploading multiple images as well as JSON data using "Content-type": "multipart/form-data" my issue is, I have nested objects to pass to the parameters I was looking for a solution, and what I find is nested data with an array of String or Int, not another custom object (I was struggling with it for so long) struct Car: Codable{ var id :Int, var name:String, var address:String, var new:Bool var users:[User] } struct User: Codable{ var id :Int, var name:String, var address:String, var age

OC与swift混编

烂漫一生 提交于 2020-12-24 07:42:24
1.第三方库的使用 1、第三方库是swift库,导入到swift项目。 用到的文件中需要:import Alamofire 2、第三方库是swift库,导入到OC项目。 不考虑 3、第三方库是OC库,导入到swift项目。 用到的文件中需要:import AFNetworking 4、第三方库是OC库,导入到OC项目。 用到的文件中需要:#import "AFNetworking.h" 但是在swift使用OC第三方时用Pod引入时曾遇见过一个问题,报错找不到该文件。 一般网上的步骤都是: 1,创建桥接文件, 2,配置文件路径 但是编译时报错: 出现问题的原因是podfile文件中少了一句:use_frameworks! 完整的代码为: target 'DaiChaoHeZi' do # Comment the next line if you're not using Swift and don't want to use dynamic frameworks use_frameworks! # Pods for DaichaoSwift pod 'SAMKeychain', '~> 1.5.3' pod 'BMKLocationKit' pod 'MJRefresh' end 参考链接:https://blog.csdn.net/kangpengpeng1/article

How Can I Access Local Https with invalid certificate With Alamofire?

末鹿安然 提交于 2020-12-06 16:04:04
问题 I'm trying to connect to a Webserver on a local network using Alamofire. If I open the url with a browser, it gives a ssl warning. If I just ignore and add the exception to the browser, it definitely works. I read different posts on this topic including Alamofire Github page, but I wasn't able to get it to work. What am I doing wrong? Thanks in advance! Here is the testing code: I declared the manager in the beginning of the code right below class ViewController. let manager = SessionManager

How Can I Access Local Https with invalid certificate With Alamofire?

我怕爱的太早我们不能终老 提交于 2020-12-06 16:01:29
问题 I'm trying to connect to a Webserver on a local network using Alamofire. If I open the url with a browser, it gives a ssl warning. If I just ignore and add the exception to the browser, it definitely works. I read different posts on this topic including Alamofire Github page, but I wasn't able to get it to work. What am I doing wrong? Thanks in advance! Here is the testing code: I declared the manager in the beginning of the code right below class ViewController. let manager = SessionManager