0
我使用NSURLConnection
從服務器下載內容(並且我正在研究iOS 5.0中的iPad應用程序)。 我希望NSURLConnection
即使在iPad待機時也能繼續下載。 有可能嗎?ios 5在待機模式下NSURLConnection和塊下載
這是我的代碼:
-(void)startDownload {
UIDevice* device = [UIDevice currentDevice];
BOOL backgroundSupported = NO;
if ([device respondsToSelector:@selector(isMultitaskingSupported)])
backgroundSupported = device.multitaskingSupported;
NSLog(@"\n\nbackgroundSupported= %d\n\n",backgroundSupported);
dispatch_async(dispatch_get_main_queue(),^{
NSURLRequest *req = [[NSURLRequest alloc] initWithURL:imageURL];
NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:req delegate:self startImmediately:NO];
[conn scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
[conn start];
if (conn) {
NSMutableData *data = [[NSMutableData alloc] init];
self.receivedData = data;
}
else { ... }
}) ;
}
謝謝!
感謝您的回覆。 不幸的是,當應用程序在後臺輸入時我沒有任何問題,但是當iPad進入待機模式時我遇到了問題 – LuZa
哦,我明白了。你準備什麼意思是「待機模式」?我認爲待機模式意味着應用程序進入後臺。 – yeesterbunny