Swift 3-Alamofire请求-将请求保存到磁盘 [英] Swift 3 - Alamofire request - Save request to disk

查看:88
本文介绍了Swift 3-Alamofire请求-将请求保存到磁盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我之所以问这个问题,是因为我没有找到有关此问题的任何资源,因此无法完成我的项目。

I am asking this question because I didn't found any resources on this issue, and therefore I can't complete my project on this.

我有这个基本的alamofire发布请求:

I have this basic alamofire post request:

let request = Alamofire.request("https://httpbin.org/post", method: .post, parameters: parameters, encoding: JSONEncoding.default)

如果我未连接到Internet ,我想保存此请求,然后在连接互联网时再次执行。

If I am not connected to the Internet, I want to save this request and then perform it again when the internet is connected.

关于如何开始此问题的任何想法?任何建议将不胜感激。

Any ideas on how to start on this issue? Any suggestion will be very much appreciated.

推荐答案


  1. 借助此答案确定
    互联网连接是否正常。

  1. With the help of this answer determine if there is working internet connection or not.

没有互联网连接的情况

将帖子参数保存为用户默认设置或文件

case when there is no internet connection
Save your post parameters in your user default or file

关注此答案以了解iphone何时再次与互联网连接

Follow this answer to get to know when iphone is again connected to internet.

借助答案在步骤2中链接的链接从
文件中读取您的参数并发出发布请求

with the help of answer linked in step 2 read your parameters from file and make the post request

这篇关于Swift 3-Alamofire请求-将请求保存到磁盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆