How to implement "check for updates" concept in iphone app -


i have pickerview showing times in minuts (5,10,20). if user select of time updates after selected time. , application run usual after 5 minutes message show updates occured.

how implement concept? coding should do?

as per guess should go threading?

you have nstimer starts when choose time pickerview.

timer = [nstimer scheduledtimerwithtimeinterval:pickervalueinseconds target:self selector:@selector(updatemethod) userinfo:nil repeats:no]; 

you choose no repeat, in updatemethod make request:

-(void)updatemethod {     nsstring *url = @"url...";     nsurlrequest *therequest=[nsurlrequest requestwithurl:[nsurl urlwithstring:someurl]                                         cachepolicy:nsurlrequestuseprotocolcachepolicy                                           timeoutinterval:20.0]; // timeout interval.      // create connection request     // , start loading data     nsurlconnection *theconnection=[[nsurlconnection alloc] initwithrequest:therequest delegate:self];      if(theconnection)      {         // create nsmutabledata hold received data.         // receiveddata instance variable declared elsewhere.         systemsdata = [[nsmutabledata data] retain];     }      else      {         // inform user connection failed.         nslog(@"nsurlconnection failed!");     }  } 

now in

-(void)connectiondidfinishloading:(nsurlconnection *)connection 

and

-(void)connection:(nsurlconnection *)connection didfailwitherror:(nserror *)error  

you take care of data or error , start new timer..

note need implement

-(void)connection:(nsurlconnection *)connection didreceiveresponse:(nsurlresponse *)response {     [systemsdata setlength:0]; } 

and

- (void)connection:(nsurlconnection *)connection didreceivedata:(nsdata *)data {     [systemsdata appenddata:data]; } 

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 -