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

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -