Reputation: 1453
I have defined a block like this:
void (^observerBlock) (id aTrigger, id aContext, void(^aTriggerCallbackBlock)(id aTContext)) = ....
Now I want to put it into an NSOperationQueue and get executed concurrently. But NSOperationQueue's instance method addOperationWithBlock:
only allows argument like this: (void (^)(void))block
.
How can I put my block with multiple arguments into an NSOperationQueue? Thanks.
Upvotes: 1
Views: 375
Reputation: 4678
One way to do this is to subclass the NSOperation
or NSBlockOperation
classes to create a specialized operation class then just add the properties you need to the subclass instead of passing the values as arguments.
Another way is to just reference the variables you need within the block and when the block gets created it will copy the references/values. If you need to be able change these values you can use __block on your variables you're referencing inside the block.
Upvotes: 1