Re: NSOperation communicating progress?
Re: NSOperation communicating progress?
- Subject: Re: NSOperation communicating progress?
- From: Kyle Sluder <email@hidden>
- Date: Sun, 03 Feb 2013 17:23:38 -0800
On Sun, Feb 3, 2013, at 05:09 PM, Todd Heberlein wrote:
> I've added an NSInvocationOperation object to process a large file
> asynchronously. Everything mostly works fine, but I am trying to add a
> way for this NSInvocationOperation object to communicate its progress
> back to the main thread (e.g., setting a percent of the file processed).
>
> I have an NSProgressIndicator value bound to a double variable
> "loadingProgressPercent", and I have the operation updating that value
> with
>
> self.loadingProgressPercent = percent_read * 100.0;
Do not do this. You'll send KVO on that property from the background
thread that's running your operation.
> Is there a common approach for an NSOperation object to communicate its
> progress back to the main thread and have that progress value update an
> NSProgressIndicator?
Have your operation post new operations back to +[NSOperationQueue
mainQueue] to update the loadingProgressPercent property.
--Kyle Sluder
_______________________________________________
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