I am trying to understand NSOperationQueue’s and am trying to create the most simple example possible. I have the following:
NSOperationQueue *myOQ=[[NSOperationQueue alloc] init];
[myOQ addOperationWithBlock:^(void){
NSLog(@"here is something for jt 2");
}];
[myOQ addOperationWithBlock:^(void){
NSLog(@"oh is this going to work 2");
}];
But would like to do this:
void (^jt)() = ^void(){
NSLog(@"here is something for jt");
};
void (^cl)() = ^void(){
NSLog(@"oh is this going to work");
};
NSOperationQueue *myOQ=[[NSOperationQueue alloc] init];
[myOQ addOperation:jt];
[myOQ addOperation:cl];
Is this latter form possible? Can I convert a block to an NSOperation?
thx in advance
You could:
Having said that, I’d generally do
addOperationWithBlockunless I really needed theNSOperationobject pointers for some other reason (e.g. to establish dependencies between operations, etc.).