Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
258 views
in Technique[技术] by (71.8m points)

AFNetWorking 做网络请求的一个问题。

manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];

这段代码是什么意思?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

manager的responseSerializer属性.它只设置了一些固定的解析格式.其中不包含text/html这种数据的格式。AFNetworking解析格式的底层,是没有text/html这种数据的格式的:

manager.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];

为了避免网络数据解析出错,添加 text/html 类型到可接收内容类型中

manager.responseSerializer.acceptableContentTypes= [NSSetsetWithObjects:@"text/html", nil];

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...