搜索
查看
编辑修改
首页
UNITY
NODEJS
PYTHON
AI
GIT
PHP
GO
CEF3
JAVA
HTML
CSS
搜索
凡人多烦事01
这个屌丝很懒,什么也没留下!
关注作者
热门标签
jquery
HTML
CSS
PHP
ASP
PYTHON
GO
AI
C
C++
C#
PHOTOSHOP
UNITY
iOS
android
vue
xml
爬虫
SEO
LINUX
WINDOWS
JAVA
MFC
CEF3
CAD
NODEJS
GIT
Pyppeteer
article
热门文章
1
linux(euler) 重启网络服务后路由表丢失问题的解决方案_欧拉系统无法添加路由
2
Verilog 顺序块、并行块,阻塞过程赋值、非阻塞过程赋值的区别_顺序块和并行块的区别
3
Java8新特性--StreamAPI_java8 stream api
4
云计算时代的运维职位展望
5
Java栈_java 栈
6
笔记连载 | Day6 FPGA三种建模方式区别及Verilog语法基础篇_fpga的建模方式
7
Windows cmake-gui 添加c++ 11 c++ 14 c++ 17_cmake 指定c++14
8
漫谈JVM热加载技术(一)---目前常见的解决方案
9
go实践十 爬虫抓取网页数据_htmlquery.findone 获取 text
10
【Linux】项目自动化构建工具——make/Makefile及拓展_linux makefile编译并安装新app
当前位置:
article
> 正文
AFNetworking使用入门(随笔和链接)_afnetworking 使用长链接
作者:凡人多烦事01 | 2024-05-27 04:44:40
赞
踩
afnetworking 使用长链接
AFNetworking是一个流行的iOS网络封装库,包括了常用的HTTP协议的使用接口,用起来很方便。被国内外很多大型APP应用。
1.安装
1)
https://github.com/AFNetworking/AFNetworking
下载下来并解压
2)以group方式,AFNetwork下面的文件都加入到工程中
3)在需要引用的地方#import “AFNetworking.h"
2.例子
1)GET一个json数据
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/plain"];
[manager GET:@"http://XXXXX" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"JSON: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
/*
完整例子:
[manager GET:@"
http://XXX
" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"JSON: %@", responseObject);
NSDictionary *a=responseObject;
NSLog(@"%@",[a valueForKey:@"version"]);
NSString *remoteVersion=[a valueForKey:@"version"];
NSString *url=[a valueForKey:@"url"];
NSString *target=[a valueForKey:@"target"];
NSString *localVersion=[self getCurrentVersion];
if (remoteVersion!=nil){
if ([remoteVersion compare:localVersion]!=NSOrderedSame){
NSLog(@"Need to download!");
[self downloadFile:url toFile:target];
}
[self writeVersion:remoteVersion];
}
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
*/
2)下载文件
-(void) downloadFile:(NSString *)fileURL toFile:(NSString*)toFile{
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration];
NSURL *URL = [NSURL URLWithString:fileURL];
NSURLRequest *request = [NSURLRequest requestWithURL:URL];
NSURLSessionDownloadTask *downloadTask = [manager downloadTaskWithRequest:request progress:nil destination:^NSURL *(NSURL *targetPath, NSURLResponse *response) {
NSURL *documentsDirectoryURL = [[NSFileManager defaultManager] URLForDirectory:NSDocumentDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:nil];
return [documentsDirectoryURL URLByAppendingPathComponent:[response suggestedFilename]];
} completionHandler:^(NSURLResponse *response, NSURL *filePath, NSError *error) {
NSLog(@"File downloaded to: %@", filePath);
}];
[downloadTask resume];
}
声明:
本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:
https://www.wpsshop.cn/w/凡人多烦事01/article/detail/629941
推荐阅读
article
一张图带你搞懂
大
数据
,
彻底了解
大
数据
经典路线?
_
大
数据
查询
图解...
什么是
大
数据
,
大
数据
有什么用
,
为什么凯文凯利说
数据
是必然
,
马云说
数据
是未来的一切的来源?世界每天都在变
,
新的概念和名词不...
赞
踩
article
selenium
自动化
测试
_
selenium
自动化
测试
...
Selenium实现自动化
测试
_
selenium
自动化
测试
selenium
自动化
测试
...
赞
踩
article
【
hiprint
】
hiprint
的使用方法(附使用
案例
)
hiprint
表格
数据传输
问题
解决办法
_h...
hiprint
打印table数据无法绑定
解决办法
事件起因:
问题
描述:
hiprint
使用教学:
hiprint
案例
(附下载地...
赞
踩
article
CSS
两种盒子
模型
_
css
和
模型
content
和
width
区别...
CSS
的两种盒子
模型
两种常用的盒子
模型
主要的区别是内容
content
width
和height分别是由什么组成的1.W3...
赞
踩
article
基于
深度
学习
的
自然语言
处理——
NLP
特征
的
案例
分析_使用
深度
学习
方法求解nlp领域问题
案例
...
基于
深度
学习
的
自然语言
处理——
NLP
特征
的
案例
分析
NLP
特征
的
案例
分析文本分类:语言识别文本分类:主题分类文本分类:作者...
赞
踩
article
面向对象编程
的
奥秘:
封装
与
继承
...
面向对象编程
中
的
封装
和
继承
是两大核心特性,它们共同构成了
面向对象编程
的
基础。通过
封装
,我们可以将数据和方法隐藏在类
的
内部...
赞
踩
article
verilog
基础
---
流水
灯_
verilog
的
led
左移
代码讲解...
在FPGA电路设计中,尽管
流水
灯
的
设计属于比较简单
的
入门级应用,但是其运用到
的
方法,是FPGA设计中最核心和最常用部分之...
赞
踩
article
我们
的
系统
检测到您
的
计算机网络
中存在异常
流量
_
工控
审计:国利网安
工控
安全
审计
系统
......
(文章来源:浙江国利网安科技有限公司)随着工业信息化
的
快速发展,工业化与信息化
的
融合趋势越来越明显,工业控制
系统
开始利用...
赞
踩
article
2024年五一
数学
建模
竞赛C
题
煤矿
深部
开采
冲击
地压危险预测思路解析及参考代码_多台
无人机
配送
问
题
数...
多台
无人机
配送
问
题
数学
建模
...
赞
踩
article
Kafka
(
分布式
发布订阅
消息
系统
) 简介_什么
是
kafka
...
原文链接:https://mp.toutiao.com/profile_v3/graphic/preview?pgc_i...
赞
踩
article
bug Error: Cannot
find
module
‘
vue
-
loader
-v16/pack...
更新,命令如下,在https://stackoverflow.com/questions/63504594/
error
-...
赞
踩
article
2023五一杯
数学
建模
C
题
思路解析 - “双
碳
”目标下低
碳
建筑
研究_五一
数学
建模
c
题
...
1 赛
题
C
题
:“双
碳
”目标下低
碳
建筑
研究“双
碳
”即
碳
达峰与
碳
中和的简称,我国力争2030年前实现
碳
达峰,2060年前实现...
赞
踩
article
深入
理解
C++
编译模式:了解
Debug
和
Release
的区别_c++
release
...
- **
Debug
模式**:这是一种面向开发过程的编译模式。它的核心在于提供丰富的调试信息,帮助开发者
理解
程序的运行过程...
赞
踩
article
2024年五
一
数学
建模
C
题
超详细解
题
思路+问
题
一
运行代码(两套)_2024五
一
杯
数学
建模
竞赛
c
题
...
为了能够更好的帮助大家,这里为大家带来详细版的
C
题
解
题
思路,希望能够对大家有所帮助。五
一
数模
C
题
分享资料链接:https...
赞
踩
article
2024年五一
数学
建模C题完整解题思路代码_
煤矿
深部
开采
冲击
地压
危险
预测...
在深部
煤矿
开采
过程中,可以监测声发射(AE)和电磁辐射(EMR)信号,电磁辐射和声发射传感器每30秒采集一个数据,可通过...
赞
踩
article
k8s
pod
在
节点
间
调度
控制...
博客作为学习笔记记录,若有理解,表述错误,欢迎指出。
k8s
起
pod
时,会通过
调度
器scheduler选择某个
节点
完成
调度
...
赞
踩
article
【实战技能】
自然
语言
处理
(
NLP
)的
案例
二:
语言
建模
和词性标注_
语言
建模
案例
...
自然
语言
处理
,前面和大家说了【新手上路常见问答】关于
自然
语言
处理
(
NLP
)【实战技能】
自然
语言
处理
(
NLP
)的
案例
一:依...
赞
踩
article
mysql
分表
tidb
_谁说
TiDB
不能搞定
分库
分表
场景
?...
最近有一些同学跟我说『
TiDB
搞不定
分库
分表
的
场景
』,实话我当时真的二丈摸不着头脑,
TiDB
从最开始设计的时候,就是...
赞
踩
article
pythonddos
监控_基于
SDN
的
DDoS
攻击
检测
与防御...
开始是在合天做
的
这个实验,想要本地复现,搭建本地环境。需要用到工具: floodlight, mininet (安装完整...
赞
踩
article
Android
13
适配_
android
13
onreachedmaxappcachesize...
1.WebChromeClient的 API onReachedMaxAppCacheSize 没了2.WebSetti...
赞
踩
相关标签
大数据
大数据开发
selenium
测试工具
前端
javascript
html5
css
python
开发语言
numpy
pandas
qt
verilog
我们的系统检测到您的计算机网络中存在异常流量
数学建模
无人机
kafka
npm
算法
c++
c语言
arm
linux