I've created NSInvocationOperationQueue
object then added it into my NSOperationQueue
instance.
operationQueue = [NSOperationQueue new];
NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(counterTask) object:nil];
[operationQueue addOperation:operation];
operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(colorRotatorTask) object:nil];
[operationQueue addOperation:operation];
It works but I have questions. This post tells me that every operation should be release, but mine without release still works and it gives me error if I release it. If I do not release, is there any side effect or something will happen? Or is there any steps I missed that caused it cannot be released?
Any help would be appreciated. Thank you.
Notice that the project being created in the link you provided doesn't use Automatic Reference Counting (ARC).
There's no reason not to be using ARC in any new project. With ARC you can avoid all of the attempts to call release
or autorelease
or retain
. ARC will properly release the added operation when it is done.
The code you posted in your question is fine with regard to memory management as long as you are using ARC. And since you are getting errors trying to call release
this means you are using ARC.