NSURLConnection 和NSURLSession的不同

Both nsurlsession and nsurlconnection work similarly at high level for most of the part.
大部分相似

nsurlsesion provides support for download task which behave same like nsurldownload class.

when we create a nsurlsession object it provides reusable(可复用的) configuration object that encapsulates(封装) many common configurations options. but for nsurlconnection object we must set those each options independently.

nsurlconnections object handles single request and any follow on request.nsurlsession handles multiple tasks each of which single url request and any follow on request.

in nsurlconnection , each connection object has separate delegate.

in nsurlsession , delegate is shared across all tasks within a session.if we need new delegate , we must create new session.

nsurlconnection is older api introduced in os x 10.2

nsurlconnection is introduced in os x 10.9 which is modern having task and block based API.

Big difference is nsurlsession provides ability to perform background downloads when app is not running.

  • encapsulates 压缩、将…装入胶囊;将…封进内部;概述 。

总结

  • 大部分相似
  • session,意思是会话,顾名思义,nsurlsession功能要多,包含上传、下载等功能
  • 每个nsurlconnection都有一个单独的代理,一个session能包含很多任务
  • 最大的不同是后台下载

英文原文链接

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值