Re: Get a NIL NSError object for second download task
Re: Get a NIL NSError object for second download task
- Subject: Re: Get a NIL NSError object for second download task
- From: Daryle Walker <email@hidden>
- Date: Wed, 08 Apr 2015 02:44:11 -0400
> On Apr 7, 2015, at 3:10 PM, Daryle Walker <email@hidden> wrote:
>
> I’m using NSURLSessionDownloadTask in a command-line tool. I just adapted it to run multiple URLs to download. The loops and task work when I enter a single URL. When I enter two, the shorter file is downloaded, but the "- URLSession: task: didCompleteWithError:” is called for the second URL, and the error parameter gets NIL as its value. I have a run loop in the main function, and I call “resume” on both tasks. Am I supposed to run the success code when I get a NIL error? But there’s a separate method for successful downloads (and that other method tells me where the new file is)! The two URLs download when I call the tool for them separately.
>
> I only have two delegate methods defined; the other is “- URLSession: downloadTask: didFinishDownloadingToURL:”.
I changed my mass-resume function to only resume the first download task. The next task is resumed within the completion or error handler. The last task calls “finishTasksAndInvalidate” for the session. The same error still happens. (The actual crash is caused by my code storing the error object, and the dictionary craps out when trying to save a NIL object.)
If it makes a difference, the session is configured to use the main thread, since tools don’t need extra threads (no GUI).
It seems that something is getting purged on the first competition/error and never reinitialized for subsequent tasks.
—
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden