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 (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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Reply via email to