我很有趣地NSSession
在不使用对象的情况下以一定的间隔重复自己NSTimer
,我正在寻找是否可以设置我忽略的NSURLRequest
或的某些属性?NSURLSessionConfiguration
问问题
411 次
1 回答
1
如果你不想使用 NSTimer,你可以使用长池技术,你可以在其中配置 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];
}
于 2015-04-20T13:27:01.567 回答