我很感兴趣的是让NSSession在不使用NSTimer对象的情况下以一定的间隔重复自己,我正在寻找是否可以设置我忽略的NSURLRequest或NSURLSessionConfiguration的一些属性?
发布于 2015-04-20 21:27:02
如果您不想使用NSTimer,您可以使用长池技术,您可以在其中配置超时间隔。
(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];
}https://stackoverflow.com/questions/29747207
复制相似问题