I have a download controller with an NSMutableArray and an
NSArrayController hooked up to a NSTableView with a view based setup.
My array contains custom download objects. Each of those has a
NSURLDownload instance.

Basically, I am showing a browser-download like interface with size
downloaded, total expected size, a progress bar, time elapsed,
download rate and estimated time left.

It is all working wonderfully, but actually too well. Right now, I am
using will/didChangeValueForKey messages to notify observers when the
number of bytes downloaded changes. I am doing this in the callback
method:

- (void)download:(NSURLDownload *)download
didReceiveDataOfLength:(NSUInteger)length
{
  [self willChangeValueForKey:@"bytesDownloaded"];
  _bytesDownloaded += length;
  [self didChangeValueForKey:@"bytesDownloaded"];
}

The result of this is that the UI updates really frequently and the
estimated time to complete and the download rate jump around a lot. I
would love it if I could tell cocoa to only update the UI once per
second instead of immediately when the property key changes.

With a bit of work I could probably set up a proxy object for each
download that would do something like that and use timer, but it would
be a lot of messy code. I could also just delay updating the
_bytesDownloaded on a queue. Or a third idea is to cache the estimated
calc time and rate and then only recalculate the value at most once
per second.

Any other brighter ideas? Thoughts?

Thank you,
Andrew
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to