Re: Is slowing down bindings updates possible?
Re: Is slowing down bindings updates possible?
- Subject: Re: Is slowing down bindings updates possible?
- From: Steve Christensen <email@hidden>
- Date: Fri, 13 Jan 2012 11:36:07 -0800
Why don't you just decouple your UI from the "by-the-millisecond" download process? For example, you could update calculated values whenever the value of bytesDownloaded changes but use a NSTimer to update the display of those values maybe once or twice a second. The display is then sampling the download process periodically rather than recording every single change, which should also reduce the amount of time spent redrawing the display.
On Jan 12, 2012, at 9:57 PM, Andrew wrote:
> 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?
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden