Not signed in (Sign In)

Vanilla 1.1.8 is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthorreeses
    • CommentTimeJan 10th 2008
     
    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:

    [[NSURLDownload alloc] initWithRequest:urlRequest delegate: self];

    isDoneWithRequest = NO;
    NSUInteger lastPctComplete = 0;
    do {
    NSDate *next = [NSDate dateWithTimeIntervalSinceNow:1.0];
    [[NSRunLoop currentRunLoop]
    runMode: NSDefaultRunLoopMode
    beforeDate: next];
    if (pctComplete != lastPctComplete) {
    [aCoreDataObject setValue:[NSString stringWithFormat:@"%dPCT", pctComplete] forKey:@"status"];
    lastPctComplete = pctComplete;
    }
    } while (!isDoneWithRequest);

    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).
    •  
      CommentAuthorjediknil
    • CommentTimeJan 10th 2008
     
    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?)
    • CommentAuthorreeses
    • CommentTimeJan 11th 2008
     
    @jediknil -

    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.
    • CommentAuthormitchellh
    • CommentTimeJan 21st 2008
     
    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?
    • CommentAuthorreeses
    • CommentTimeJan 24th 2008
     
    @mitchellh

    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.