[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How do I cancel a NSURL loadResourceDataNotifyingClient:usingCache: ?



On Saturday, March 2, 2002, at 09:48 PM, Gerben Wierda wrote:

>     [[_downloadingURL URLHandleUsingCache:YES] cancelLoadInBackground];

When you begin downloading, store a reference to the NSURLHandle. Call 
beginLoadInBackground on your URLHandle. Later on, call 
cancelLoadInBackground on your URLHandle. What you are doing here is 
creating a new NSURLHandle for that URL, and telling it to cancel 
loading -- this does nothing as it isn't even loading in the first 
place! :-)

So instead of doing [aURL loadResourceDataNotifyingClient:usingCache:], 
do

NSURLHandle *aURLHandle = [aURL URLHandleUsingCache:YES];
[aURLHandle addClient:self];
[aURLHandle beginLoadInBackground];
...
[aURLHandle cancelLoadInBackground];

All conceptual code, might not compile :-)

  -- Finlay