我用IOS7asihttprequest下載文件,但關機時,屏幕鎖
我開始下載和我鎖屏,和我開屏。我的程序正在關閉...
有沒有一些可以幫助我?
這是主要代碼:
初始化下載網址:
NSURL *url = [NSURL URLWithString:dictionaryUrl];
ASIHTTPRequest *request = [[ASIHTTPRequest alloc] initWithURL:url];
集ASIHTTPRequest代表:
request.delegate = self;
init文件保存路徑:
NSString *savePath = [path stringByAppendingPathComponent:name];
bool b=[ fileManager createFileAtPath :savePath contents : nil attributes : nil ];
if (b){
fileHandle=[ NSFileHandle fileHandleForWritingAtPath :savePath];
}
[request setAllowResumeForFileDownloads:NO];
[request setDelegate:self];
[request setDidFinishSelector:@selector(requestDone:)];
[request setDidFailSelector:@selector(requestWentWrong:)];
[request setDataReceivedBlock :^(NSData * data){
[fileHandle seekToEndOfFile ];
[fileHandle writeData :data];
[ label setText :[ NSString stringWithFormat : @"downloading...%.1f %%" , process . progress * 100 ]];
}];
[request setDownloadProgressDelegate:process];
添加到ASINetw orkQueue:
[self.netWorkQueue addOperation:request];
RELASE要求:
[request release];
的確[在此博客條目幫助你走出詳細]的(http://www.xcubelabs.com/blog/ios-7-background-execution-and-multitasking/)? –