views:

16

answers:

1
NSOperation *operation = /*some operation*/;
[operationQueue addOperation:operation];

// …
// Some work
// …

return Value;

I want to get Value from function before operation ends.

A: 

As far as I know, you can't.
You may wait for an operation to be done, but trying to preempt a threadpool task is somewhat pointless.
Even if you managed to pause/suspend the queue before you add your operation, you still have to resume it before you return, and you have no way to avoid a possible context switch at this point.
If the Value being returned is a shared var/global/field which might get modified by the operation, you may copy/clone its current value into a tempvar/local before the addOperation to return it later.

Viktor Svub