• 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
Re: NSOperation communicating progress?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >NSOperation communicating progress? (From: Todd Heberlein <email@hidden>)

  • Prev by Date: NSOperation communicating progress?
  • Next by Date: Re: new to Cocoa/Objective-c: many points of confusion
  • Previous by thread: NSOperation communicating progress?
  • Next by thread: Re: NSOperation communicating progress?
  • Index(es):
    • Date
    • Thread