I know I can call [NSOperation waitUntilFinished]
to wait for an NSOperation, but is there a way to include the completionBlock as part of this wait call? Right now I set a BOOL in the completion block to indicate that the operation is finished including the completion block, but surely there must be a better, built in way to do it...
[self.requestOperation setCompletionBlock:^{ self.reallyDone = YES; }];
You don't need a completion block with waitUntilFinished
. Just put it on the next line after the call to waitUntilFinished
. That next line won't be reached until the operation completes achieving precisely the same functionality as a completion block.
You only need to use completion blocks when you're doing something asynchronously, but if you're invoking the operation synchronously, that obviates the need for completion block.