Laur Stefan
Laur Stefan

Reputation: 1579

How to make a NSURLSession repeat at a certain interval?

I am interesting to make NSSession repeat itself at a certain interval without using an NSTimer object, I am looking if I can set some property of the NSURLRequest or of the NSURLSessionConfiguration that I have overlooked?

Upvotes: 2

Views: 429

Answers (1)

Clo
Clo

Reputation: 31

if you don't want to use NSTimer, you can use long pool technic, in which you can configure the timeoutinterval.

(void)longPoll
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSMutableURLRequest *request    = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:url] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30];

// --- Your code ---

[request release];
[pool drain];

[self performSelectorInBackground:@selector( longPoll ) withObject:nil];
}

Upvotes: 1

Related Questions