In my application I need to send request to server to get xml after particular time interval say 1 hour to get the latest data.I want to perform this activity in background.Can anyone suggest how I can achieve this?
Thanks in advance!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To solve above problem I created NSOperation to send request to server and parse response.Its very useful and better than using thread.
1.I created NSTimer instance which will call -(void)sendRequestToGetData:(NSTimer *)timer after particular time interval as follows:
2.Then inside sendRequestToGetData I created NSOperation by subclassing NSOperation as follows:
Note: DataDownloadOperation is subclass of NSOperation.