• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
usingCache:YES doesn't.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

usingCache:YES doesn't.


  • Subject: usingCache:YES doesn't.
  • From: Angela Brett <email@hidden>
  • Date: Tue, 30 Dec 2003 23:23:59 +1300

Hi,

I have some code for downloading a file, displaying a progress bar for the download, and then saving the file and doing something with it. A reasonable enough thing to do, and it all works, except for a problem which I've been able to ignore until now. When the URL has finished loading, and I send it a resourceDataUsingCache:YES message, I suspect the data is being downloaded all over again... if I step over that line in the debugger there is a pause about as long as the download took. Here's a sample of the code:

[URL loadResourceDataNotifyingClient:self usingCache:YES];

- (void)URLResourceDidFinishLoading:(NSURL *)sender {
if (status==ACUpdateRetrieving) { //just making sure I was actually downloading
NSData *data=[sender resourceDataUsingCache:YES];
//some other code
}
}

I have implemented other methods such as URLResourceDidCancelLoading:, resourceDidFailLoadingWithReason: and resourceDataDidBecomeAvailable:, just to do simple things like display error messages and update a progress bar. As would be expected, when I'm connected to the internet resourceDataDidBecomeAvailable: is called many times and the other two methods aren't. It sure seems as though the data gets loaded before URLResourceDidFinishLoading: is called. But the line:

NSData *data=[sender resourceDataUsingCache:YES];

just loads it all again. As I understand the documentation, resourceDataUsingCache:YES should return immediately with the data which has already been loaded.

I know I could work around this by saving the data as it arrives in resourceDataDidBecomeAvailable:, but it bothers me that resourceDataUsingCache:YES doesn't seem to be working according to the documentation. I can't imagine what I could be doing wrong, can anybody?
--
Angela Brett email@hidden http://macintosh.geek.nz
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
  • Prev by Date: Re: handling of huge bitmaps, incremental saving?
  • Next by Date: Re: handling of huge bitmaps, incremental saving?
  • Previous by thread: Re: I would like to drag a view in real time
  • Next by thread: Change NSAlertPanel into Textured Style
  • Index(es):
    • Date
    • Thread