Directly on the code ...
You can use nsurlsession after iOS7, but consider iOS6 or use nsurlconnection.
@interface Viewcontroller () <NSURLConnectionDataDelegate> @property (nonatomic,strong) Nsmutabledata *receiveddata;@ End@implementation viewcontroller-(void) viewdidload {[Super viewdidload]; Nsurlrequest *therequest = [nsurlrequest requestwithurl:[nsurl urlwithstring:@ "http://www.baidu.com"] Cachepolicy:nsurlrequestuseprotocolcachepolicy Timeo utinterval:10.0]; Nsurlconnection *theconncetion=[[nsurlconnection alloc] initwithrequest:therequest delegate:self]; if (theconncetion) {_receiveddata = [nsmutabledata data]; }}-(void) connection: (Nsurlconnection *) connection didreceivedata: (NSData *) data {[_receiveddata appenddata:data]; NSLog (@ "Downloading ..."); -(void) connectiondidfinishloading: (nsurlconnection *) connection {NSLog (@ "finished");} @end
[IOS] A small example of nsurlconnection