TWRDownloadManager
TWRDownloadManager copied to clipboard
didFinishDownloadingToURL crash
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[NSURL URLByAppendingPathComponent:]: component, components, or pathExtension cannot be nil.' *** First throw call stack: ( 0 CoreFoundation 0x0000000103c393f5 exceptionPreprocess + 165 1 libobjc.A.dylib 0x00000001038d2bb7 objc_exception_throw + 45 2 CoreFoundation 0x0000000103c3932d +[NSException raise:format:] + 205 3 Foundation 0x00000001013af1f2 -[NSURL(NSURLPathUtilities) URLByAppendingPathComponent:] + 84 4 islami 0x00000001001c1d06 -[TWRDownloadManager URLSession:downloadTask:didFinishDownloadingToURL:] + 774 5 CFNetwork 0x0000000100a33820 __82-[NSURLSession delegate_downloadTask:didFinishDownloadingToURL:completionHandler:]_block_invoke + 38 6 Foundation 0x0000000101476ccf __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK + 7 7 Foundation 0x00000001013b6b32 -[NSBlockOperation main] + 98 8 Foundation 0x0000000101399104 -[__NSOperationInternal _start:] + 645 9 Foundation 0x0000000101398d13 __NSOQSchedule_f + 184 10 libdispatch.dylib 0x0000000104c177f4 _dispatch_client_callout + 8 11 libdispatch.dylib 0x0000000104bffbf4 _dispatch_queue_drain + 1417 12 libdispatch.dylib 0x0000000104bff506 _dispatch_queue_invoke + 235 13 libdispatch.dylib 0x0000000104c01ff7 _dispatch_root_queue_drain + 682 14 libdispatch.dylib 0x0000000104c0363c _dispatch_worker_thread2 + 52 15 libsystem_pthread.dylib 0x0000000104fadef8 _pthread_wqthread + 314 16 libsystem_pthread.dylib 0x0000000104fb0fb9 start_wqthread + 13 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)
It seems like there's something wrong with the file URL you are trying to download
'NSInvalidArgumentException', reason: '*** -[NSURL URLByAppendingPathComponent:]: component, components, or pathExtension cannot be nil.'
What is the URL you are passing in?
im passing url like this http://www.mysite.com/media/xyzi-abcd-8-my-wife-intro.mp3
after some debuging i notice that it goes directly to
- (void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didFinishDownloadingToURL:(NSURL *)location {
and download.fileName and download.directoryName is returning nill
any idea, thank you
i have the same crash.why?
I also have this issue and have been debugging it for a while now. Can anyone shine a light on this?
Same problem. I can reproduce it every time by terminating the app while a download is in progress then restarting the app and accessing [TWRDownloadManager sharedManager].
It crashes because the TWRDownloadObject on line 222 of TWRDownloadManager.h is nil. It appears that NSURLSession is still attempting to complete the download, but TWRDownloadManager no longer has a reference to it in self.downloads.
I have also tested this following what @bonebox reported, I also get this crash when I have a download running for a long time in the background. Could a possible solution be creating temp/cached download config files in the apps filesystem instead of using an array, referenced by the download location and deleting as we're done with them?
@DevelopIdeas I have the same crash and I think that might be a good idea.