Re: NSOperation and waitUntilFinished
Re: NSOperation and waitUntilFinished
- Subject: Re: NSOperation and waitUntilFinished
- From: Jonathan Hull <email@hidden>
- Date: Sat, 20 Oct 2012 11:55:27 -0700
You probably want to be using -addDependency:
-waitUntilAllOperationsAreFinished just blocks the thread it is called on until the receiver finishes (thus if you call it on the same thread as the queue, it will block it forever).
If you need to do something after the operation is done which is not an operation itself, then you probably want to look at -setCompletionBlock:. The block you provide will get called once the operation is complete (and let you clean things up, etc…). Note that the block may not be called on the main thread.
Thanks,
Jon
On Oct 20, 2012, at 10:15 AM, Koen van der Drift <email@hidden> wrote:
>
> On Oct 20, 2012, at 12:53 PM, Gary L. Wade <email@hidden> wrote:
>
>> At the time when you call waitUntilAllOperationsAreFinished, no operations have been added, so there's nothing to wait on. Add the operation to the queue first and then call wait.
>> --
>
> I tried that too, but then it just stays in the operation and never finishes:
>
> start import
> begin of importRecords in operation
>
> and nothing else, it just sits there.
>
> - Koen.
> _______________________________________________
>
> 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
>
_______________________________________________
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