iphone - How to cancel the link like this? -
i used nstimer update data in link every seconds,and method this:
nsstring *url=[nsstring stringwithformat:@"http://disca.malauu.com/jsbfall.txt"]; nserror *error=[nsstring stringwithformat:@"you error"]; nsstring *urldata=[nsstring stringwithcontentsofurl:[nsurl urlwithstring:url] encoding:nsutf8stringencoding error:&error]; nslog(@"urlstring:%@",urldata);
and if network conges,the connection connect long time.how can cancel if link doesn't update data half of second? can me answer,think much!
if think implement using nsurlconnection
, delegate pattern allow cancel connection, , set options timeout.
second advantage request performed asynchronously, , won't block execution of app, if network doesn't answer immediatly.
you find more information way, on nsurlconnection class reference page, , in url loading system programming guide.
Comments
Post a Comment