I'm not sure if I have a Core Data issue, an NSURLDownload issue, or an NSOperation issue. It looks as if I have a delegate message going to the wrong object. I am attempting to update the download's percentage complete (every 25%) on a Core Data object. I have one thread (the NSOperation) kicking off the download and monitoring the progress, and the NSURLDownload is doing its thing in another thread, with the app in the main thread. In this block of code in the NSOperation subclass:
I have intermittent failures with a debug message like: *** -[__NSCFDate sendDidReceiveResponse:]: unrecognized selector sent to instance 0x107f9c0 or *** -[NSCFArray sendDidReceiveResponse:]: unrecognized selector sent to instance 0x1063d10 or *** -[NSCFNumber sendDidReceiveResponse:]: unrecognized selector sent to instance 0x1060e40
The thread stack processing the run loop and message appears to be coherent.
I suspect this is a common (ish) issue and I just haven't found the documentation yet because I'm not searching on anything general enough.
For completeness, I'm using the code for displaying progress from here http://developer.apple.com/documentation/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLDownload.html#//apple_ref/doc/uid/20001839-165094 (which is where I'm updating pctComplete).
No, I don't have an answer myself, but 98 times out of 100 this kind of error means that something is being deallocated; in this case your delegate. Is there any possibility your delegate's retain count is hitting 0 early? (Or the equivalent for GC?)
That's what I was thinking, too, but the delegate wasn't getting collected at that point, according to the debugger. I poked down a little further and did see that a downloadResponse (given in a callback) I was storing in a property in the delegate appeared to be getting collected. I didn't need the whole response so I just stored the one thing I did need and the problem went away. I suspect I fat fingered a reference key or had a misspelling that I wasn't able to see and the compiler didn't look at.
I am having this problem too. I'm very confused what's going on as it seems like I am downloading correctly... I actually need the download to complete and because of these errors it is not. How did you get rid of them?
I'm not at the machine with the code right now, but I was saving the NSURLResponse in the current instance. All I really needed was to save expectedContentLength from that response. Instead of saving (and somehow losing) the response, I just added an instance variable for the expectedContentLength. Since it's a primitive and not an object, I didn't have to worry about it getting collected and everything has been going along just fine. I don't generally like breaking encapsulation in that way, but I figured it was relatively low risk as I'll update it if my delegate methods receive a message.